Skip to content

Commit 8f47976

Browse files
author
Jean-Baptiste Theou
committed
cdc: fix line_coding aligment
While calling tud_cdc_n_get_line_coding, the structure is copied into the destination. Dump of assembler code for function tud_cdc_n_get_line_coding: 0x000193f4 <+0>: mov.w r2, hathach#2112 @ 0x840 0x000193f8 <+4>: ldr r3, [pc, hathach#20] @ (0x19410 <tud_cdc_n_get_line_coding+28>) 0x000193fa <+6>: mla r0, r2, r0, r3 => 0x000193fe <+10>: ldr.w r3, [r0, hathach#6] 0x00019402 <+14>: str r3, [r1, #0] On some platform (tested on LPC55S28), the address needs to be 4-bytes aligned. Without this, the address is (gdb) p &_cdcd_itf.line_coding $3 = (cdc_line_coding_t *) 0x40100006 <_cdcd_itf+6> which leads to a HardFault. With this fix (gdb) p &_cdcd_itf.line_coding $5 = (cdc_line_coding_t *) 0x40100008 <_cdcd_itf+8> and the function can be called properly Signed-off-by: Jean-Baptiste Theou <[email protected]>
1 parent e3b3229 commit 8f47976

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/class/cdc/cdc_device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ typedef struct
5353

5454
/*------------- From this point, data is not cleared by bus reset -------------*/
5555
char wanted_char;
56-
cdc_line_coding_t line_coding;
56+
CFG_TUSB_MEM_ALIGN cdc_line_coding_t line_coding;
5757

5858
// FIFO
5959
tu_fifo_t rx_ff;

0 commit comments

Comments
 (0)