Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug where data were not uploaded properly if data size was not a multiple of 32 bits #35

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion bootloader07/bootloader07.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ int notmain ( void )
unsigned int data;
unsigned int sum;
unsigned int ra;
// Keeps track of byte_count when reading data
unsigned int counter;
// Keeps track of number of characters read
unsigned int unit_counter;

uart_init();
hexstring(0x12345678);
Expand All @@ -60,6 +64,8 @@ int notmain ( void )
record_type=0;
address=0;
byte_count=0;
counter=0;
unit_counter=0;
while(1)
{
ra=uart_recv();
Expand Down Expand Up @@ -138,6 +144,8 @@ int notmain ( void )
{
case 0x00:
{
counter = 0;
unit_counter = 0;
state=14;
break;
}
Expand Down Expand Up @@ -187,20 +195,32 @@ int notmain ( void )
case 20:
case 21:
{
if (counter > 2 * byte_count) {
break;
}
unit_counter++;
counter++;
data<<=4;
if(ra>0x39) ra-=7;
data|=(ra&0xF);
if(state==21)
if(unit_counter == 8 || counter == 2 * byte_count)
{
ra=(data>>24)|(data<<24);
ra|=(data>>8)&0x0000FF00;
ra|=(data<<8)&0x00FF0000;
data=ra;
// 8 * 4bits = 32 bits
if (unit_counter != 8) {
// Left with a value that is not 32bits wide
int left=byte_count%sizeof(int);
data>>=32-left*8;
}
PUT32(address,data);
sum+=address;
sum+=data;
address+=4;
state=14;
unit_counter=0;
}
else
{
Expand Down
Binary file modified bootloader07/bootloader07.o
Binary file not shown.
Binary file modified bootloader07/bootloader07_rpi2.elf
Binary file not shown.
126 changes: 88 additions & 38 deletions bootloader07/bootloader07_rpi2.hex
Original file line number Diff line number Diff line change
Expand Up @@ -129097,43 +129097,93 @@
:100270000400A0E10C109FE563FFFFEB1040BDE818
:100280001EFF2FE108B4003F0002F90010402DE9E5
:1002900008009FE562FFFFEB1040BDE81EFF2FE165
:1002A00020B4003FF0472DE90080A0E3A6FFFFEB5C
:1002B00040029FE59DFFFFEB5BFFFFEB9BFFFFEB2A
:1002C0004900A0E375FFFFEB4800A0E373FFFFEBDD
:1002D0004500A0E371FFFFEB5800A0E36FFFFFEBC9
:1002E0000D00A0E36DFFFFEB0A00A0E30890A0E182
:1002F0000860A0E10850A0E10870A0E10840A0E17A
:1003000066FFFFEB52FFFFEB3A0050E32B00000AC1
:100310000D0050E30A00501301A0A00300A0A01399
:100320002900000A2030C0E3470053E35000000AD0
:10033000013044E2140053E303F19F97F0FFFFEA1A
:10034000B0032000B003200050042000500420001F
:10035000500420005004200030042000F803200046
:10036000D4032000D4032000D4032000D4032000B1
:10037000C80320009403200094032000940320006D
:100380009403200094032000940320009403200091
:1003900094032000390050E3070040820992A0E155
:1003A0000F0000E2150054E3099080E14500000AC7
:1003B00027FFFFEB3A0050E3014084E2D3FFFF1A2E
:1003C0000140A0E3CEFFFFEA0662A0E10040A0E307
:1003D000CBFFFFEA390050E3070040820662A0E14C
:1003E0000F0000E2066080E10668A0E12668A0E157
:1003F000014084E2C2FFFFEA390050E30700408277
:100400000552A0E10F0000E2055080E1FF5005E237
:10041000010055E32700000A0E40A033B8FFFF3A61
:10042000020055E30940A0030040A013B4FFFFEA17
:10043000390050E3070040820552A0E10F0000E2BE
:10044000055080E1FF5005E20840A0E3ACFFFFEA61
:10045000390050E3070040820772A0E10F0000E27C
:10046000077080E10778A0E1277886E1014084E207
:10047000A3FFFFEA0D00A0E308FFFFEB2D00A0E3C0
:1004800006FFFFEB2D00A0E304FFFFEB0D00A0E350
:1004900002FFFFEB0A00A0E300FFFFEB0A00A0E36E
:1004A000FEFEFFEB0209A0E3E1FEFFEB0A00A0E184
:1004B000F047BDE81EFF2FE10800A0E11BFFFFEBA6
:1004C0000040A0E38EFFFFEA693829E02334A0E171
:1004D000FF3CC3E3699423E00700A0E1088087E0C4
:1004E0000910A0E1C8FEFFEB088089E0047087E2F4
:0C04F0000E40A0E382FFFFEA78563412B1
:1002A00020B4003FF04F2DE90040A0E304A0A0E1FE
:1002B0000490A0E10460A0E10450A0E10480A0E16A
:1002C0000470A0E114D04DE29FFFFFEB38059FE5DD
:1002D00096FFFFEB54FFFFEB94FFFFEB6900A0E3F9
:1002E0006EFFFFEB6800A0E36CFFFFEB6500A0E38F
:1002F0006AFFFFEB7800A0E368FFFFEB0D00A0E3CF
:1003000066FFFFEB0A00A0E308408DE504408DE5A1
:10031000F8B49FE561FFFFEB04109DE504108DE547
:100320004BFFFFEB3A0050E32200000A0D0050E3C0
:1003300004109DE53200000A0A0050E38A00000A1A
:100340002030C0E3470053E37300000A013041E26C
:10035000140053E303F19F97EFFFFFEAEC0720003F
:10036000EC072000700620007006200070062000B8
:1003700070062000C005200000062000280720008D
:10038000280720002807200028072000AC052000AF
:10039000C4062000C4062000C4062000C4062000B5
:1003A000C4062000C4062000C4062000C4062000A5
:1003B0000540A0E105A0A0E125FFFFEB3A0050E3D6
:1003C0007100000A0D0050E30A0050131500000AE6
:1003D0002030C0E3470053E34F00000A0210A0E3BF
:1003E000390050E3070040820772A0E10F0000E2ED
:1003F000077080E1FF7007E2C7FFFFEA0540A0E158
:1004000005A0A0E112FFFFEB3A0050E3E9FFFF0A6D
:100410000D0050E30A0050130200000A2000C0E360
:10042000470050E33C00000A09FFFFEB3A0050E3AD
:10043000E0FFFF0A0D0050E3F1FFFF0A0A0050E35E
:100440004900000A2000C0E3470050E33200000AE0
:10045000FFFEFFEB3A0050E3D6FFFF0A0D0050E32A
:10046000E7FFFF0A0A0050E33F00000A2000C0E354
:10047000470050E32800000AF5FEFFEB3A0050E386
:10048000CCFFFF0A0D0050E3DDFFFF0A0A0050E336
:100490003500000A2000C0E3470050E31E00000AB8
:1004A0000010A0E39CFFFFEA691829E02114A0E1F5
:1004B000FF1CC1E3699421E03993A0E10800A0E1A9
:1004C0000910A0E10C308DE504208DE5CEFEFFEB98
:1004D00008309DE5081089E0013083E008308DE5A3
:1004E000DBFEFFEB3A0050E3048088E2BC00000A28
:1004F0000D0050E30A0050130140A0030040A01378
:100500008F00000A2010C0E3470051E304209DE55E
:100510000E10A0E30C309DE56D00001A0D00A0E365
:10052000DEFEFFEB2D00A0E3DCFEFFEB2D00A0E3E1
:10053000DAFEFFEB0D00A0E3D8FEFFEB0A00A0E31C
:10054000D6FEFFEB0A00A0E3D4FEFFEB0209A0E316
:10055000B7FEFFEB0000A0E314D08DE2F04FBDE842
:100560001EFF2FE10540A0E105A0A0E1B8FEFFEBD2
:100570003A0050E38FFFFF0A0D0050E3A0FFFF0A8F
:100580000A0050E3A4FFFF1AA6FFFFEAB0FEFFEB4C
:100590003A0050E387FFFF0A0D0050E398FFFF0A7F
:1005A0000A0050E389FFFF1AEFFFFFEAA8FEFFEB06
:1005B0003A0050E30662A0E194FFFF1A7DFFFFEAD4
:1005C000390050E3070040820F0000E20552A0E12D
:1005D000055080E19EFEFFEB3A0050E3FF5005E23C
:1005E00074FFFF0A0D0050E385FFFF0A0A0050E385
:1005F000DDFFFF0A2030C0E3470053E3C6FFFF0AD8
:10060000390050E3070040820552A0E10F0000E2EC
:10061000055080E1FF5005E2010055E33B00000A70
:100620001B00003A020055E375FFFF1A88FEFFEB3E
:100630003A0050E35FFFFF0A0D0050E30A00501339
:1006400078FFFF0A2030C0E3470053E3B2FFFF0A00
:100650000A10A0E3390050E3070040820662A0E1DF
:100660000F0000E2066080E10B6006E02AFFFFEA6F
:10067000390050E3070040820882A0E10F0000E249
:10068000088080E10B8008E0088086E1011081E2AB
:1006900021FFFFEA6EFEFFEB3A0050E34D00000A37
:1006A0000D0050E30A0050132800000A2030C0E378
:1006B000470053E398FFFF0A0540A0E10E10A0E3B6
:1006C00005A0A0E1033007E2043063E28331A0E13A
:1006D0008720A0E10A0052E10FFFFF3A390050E302
:1006E00007004082014084E20992A0E10F0000E28D
:1006F000080054E301A08AE2099080E10B00000A9F
:100700000A0052E167FFFF0A011081E202FFFFEADF
:1007100008009DE585FEFFEB4DFEFFEB3A0050E340
:100720003AFFFF1A23FFFFEA011081E2C8FFFFEA48
:10073000691829E02114A0E1FF1CC1E3699421E0BC
:100740005DFFFFEA0040A0E30410A0E1F2FEFFEA33
:100750003FFEFFEB3A0050E31E00000A0D0050E39D
:1007600025FFFF0A0A0050E32100000A2000C0E331
:10077000470050E368FFFF0A35FEFFEB3A0050E305
:100780001400000A0D0050E31C00000A0A0050E3A8
:1007900073FFFF0A2000C0E3470050E35EFFFF0A3B
:1007A0002BFEFFEB3A0050E300FFFF0A0D0050E381
:1007B0001200000A0A0050E369FFFF0A2000C0E3AC
:1007C000470050E354FFFF0A0540A0E105A0A0E167
:1007D0000510A0E1D0FEFFEA0540A0E105A0A0E1E0
:1007E000F4FEFFEA0040A0E3F2FEFFEA011081E21E
:1007F000FAFEFFEA0540A0E105A0A0E15AFFFFEAEA
:100800000540A0E105A0A0E1FDFEFFEA7856341204
:04081000FFFF0000E6
:040000030000800079
:00000001FF
Loading