Hello,

I would like to impl. FW checksuming for STM8. I was unable to find
out how to access l_DATA/s_DATA from C. Looks like all C symbols are
prefixed with "_" and there is no way to generate "l_DATA"/"s_DATA"
within C.

extern uint16_t l_DATA;
extern uint16_t s_DATA;

static
uint16_t calc_fw_checksum(void)
{
    uint16_t crc16 = UINT16_C(0xFFFF);
    { // .text & data sections
        uint8_t *begin = (uint8_t*)((uint16_t)&l_DATA);
        const uint8_t *const end = (uint8_t *)((uint16_t)&l_DATA) + s_DATA;

        while(begin != end) crc16 = crc16_update(crc16, *begin++);
    }
    return crc16;
}

I have similar code for GCC/AVR.
https://github.com/wdl83/rgb_strip_lamp/blob/master/rtu_cmd.c

Thanks.
-- 
BR/Pozdrawiam. Wlodzimierz Lipert


_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to