-
Notifications
You must be signed in to change notification settings - Fork 894
Open
Description
Hi
There are several issues when an user try to compile serial recovery feature with IAR toolchain.
First one is in boot_serial_priv.h
struct nmgr_hdr {
#if (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
uint8_t _res1:3;
uint8_t nh_version:2;
uint8_t nh_op:3; /* NMGR_OP_XXX */
#else
uint8_t nh_op:3; /* NMGR_OP_XXX */
uint8_t nh_version:2;
uint8_t _res1:3;
#endif
uint8_t nh_flags;
uint16_t nh_len; /* length of the payload */
uint16_t nh_group; /* NMGR_GROUP_XXX */
uint8_t nh_seq; /* sequence number */
uint8_t nh_id; /* message ID within group */
} __packed;
IAR doesn't define __BYTE_ORDER__ and __ORDER_BIG_ENDIAN__ so equation is evaluated as 0 == 0 which leads to the structure handled as big endian. I assume the Zephyr has adaptation code what handles this situation, however for bare-metal use case this should be fixed.
Second problem is with attribute __packed. Similar issue was fixed for image.h in this PR.
I have fixed on my side with this approach
#if defined(__IAR_SYSTEMS_ICC__)
#define STRUCT_PACKED __packed struct
#define __ORDER_BIG_ENDIAN__ 1
#define __ORDER_LITTLE_ENDIAN__ 2
#if defined(__LITTLE_ENDIAN__)
#if __LITTLE_ENDIAN__ == 1
#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
#else
#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__
#endif /* __LITTLE_ENDIAN__ == 1 */
#endif
#elif defined(__GNUC__)
#define STRUCT_PACKED struct __attribute__((__packed__))
#else
#error "Unknown toolchain"
#endif
STRUCT_PACKED nmgr_hdr {
#if (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
uint8_t _res1:3;
uint8_t nh_version:2;
uint8_t nh_op:3; /* NMGR_OP_XXX */
#else
uint8_t nh_op:3; /* NMGR_OP_XXX */
uint8_t nh_version:2;
uint8_t _res1:3;
#endif
uint8_t nh_flags;
uint16_t nh_len; /* length of the payload */
uint16_t nh_group; /* NMGR_GROUP_XXX */
uint8_t nh_seq; /* sequence number */
uint8_t nh_id; /* message ID within group */
};
Third problem are defines EINVAL, EBADMSG, EADDRINUSE and ENOMSG across the serial recovery code. This is also unknown to IAR as errno.h doesn't define those.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels