STM32: I2C Master does not generate START bit
The problem was in the initialization. I have used libopencm3 APIs for initialization and the code didn't hang after generating START bit. It's possible I have not initialized RCC propertly (for GPIOB), and the I2C therefore got stuck waiting for SB which was never going to be generated. Just for a reference, I am posting my new init code, which is mostly copied from libopencm3's STM32 I2C example:

void i2c_init(void) {
    /* Enable clocks for I2C2 and AFIO. */
    rcc_periph_clock_enable(RCC_I2C2);
    rcc_periph_clock_enable(RCC_GPIOB);
    rcc_periph_clock_enable(RCC_AFIO);

    /* Set alternate functions for the SCL and SDA pins of I2C2. */
    gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_50_MHZ,
              GPIO_CNF_OUTPUT_ALTFN_OPENDRAIN,
              GPIO_I2C2_SCL | GPIO_I2C2_SDA);

    /* Disable the I2C before changing any configuration. */
    i2c_peripheral_disable(I2C2);

    /* APB1 is running at 36MHz. */
    i2c_set_clock_frequency(I2C2, I2C_CR2_FREQ_36MHZ);

    /* 400KHz - I2C Fast Mode */
    i2c_set_fast_mode(I2C2);

    /*
     * fclock for I2C is 36MHz APB2 _ cycle time 28ns, low time at 400kHz
     * incl trise _ Thigh = 1600ns; CCR = tlow/tcycle = 0x1C,9;
     * Datasheet suggests 0x1e.
     */
    i2c_set_ccr(I2C2, 0x1e);

    /*
     * fclock for I2C is 36MHz _ cycle time 28ns, rise time for
     * 400kHz =&gt; 300ns and 100kHz =&gt; 1000ns; 300ns/28ns = 10;
     * Incremented by 1 _ 11.
     */
    i2c_set_trise(I2C2, 0x0b);

    /*
     * This is our slave address - needed only if we want to receive from
     * other masters.
     */
    i2c_set_own_7bit_slave_address(I2C2, 0x32);

    /* If everything is configured _ enable the peripheral. */
    i2c_peripheral_enable(I2C2);
}