[U-Boot] [U-boot] Question about bootp structure pack
Eric BOUXIROT
rickou at rickou.net
Sun Feb 26 06:27:42 UTC 2017
Hi everyone,
I’m using u-boot-2015.07 in one of my project based on vpac270 soc module.
u-boot is well configured and build is fine without error.
Gcc is v3.4.5 and glibc v2.3.6 built by crosstool 0.43 for
arm-softfloat-linux-gnu
My problem is when i use DHCP command to retrieve a file from my TFTP
server, i can’t get any IP from the DHCP server.
After analysing ethernet frames on server side i found that frame do not
arrive at all on server.
After checking debug détails on U-boot, it seem bootp frame is not good
because of some 0x00 paddings Inside the frame. (at end of header for
example)
If i add the attribute packed to the bootp header struct and ethernet
header, now all is working fine !
In net/bootp.h :
struct bootp_hdr {
u8 bp_op; /*
Operation */
# define OP_BOOTREQUEST 1
# define OP_BOOTREPLY 2
u8 bp_htype; /* Hardware
type */
# define HWT_ETHER 1
u8 bp_hlen; /*
Hardware address length */
# define HWL_ETHER 6
u8 bp_hops; /* Hop
count (gateway thing) */
u32 bp_id; /*
Transaction ID */
u16 bp_secs; /* Seconds
since boot */
u16 bp_spare1; /*
Alignment */
struct in_addr bp_ciaddr; /* Client IP
address */
struct in_addr bp_yiaddr; /* Your (client) IP
address */
struct in_addr bp_siaddr; /* Server IP
address */
struct in_addr bp_giaddr; /* Gateway IP
address */
u8 bp_chaddr[16]; /* Client
hardware address */
char bp_sname[64]; /* Server host
name */
char bp_file[128]; /* Boot file
name */
char bp_vend[OPT_FIELD_SIZE]; /*
Vendor information */
} __attribute__((packed));
#define BOOTP_HDR_SIZE sizeof(struct bootp_hdr)
And in include/net.h
struct ethernet_hdr {
u8 et_dest[6]; /*
Destination node */
u8 et_src[6]; /*
Source node */
u16 et_protlen; /* Protocol
or length */
} __attribute__((packed));
I think the uboot src should work as is, because I have checked uboot
source modification since 2015.07, but no changes on the struct definition
and header_size still made with sizeof(struct).
So i think, the problem come from my side and perhaps from gcc itself.
But i don’t understand why gcc should pack these structs.. i think normal
use is to not pack.. except if makefile include some build option to do
that, my gcc toolchain do not understand..
Someone can help me to understand what i made wrong ? and help me to
resolve this problem without patching ?
More information about the U-Boot
mailing list