View previous topic :: View next topic |
Author |
Message |
Hans Wedemeyer
Joined: 15 Sep 2003 Posts: 226
|
Bootloader in Wrong segment |
Posted: Sun Sep 02, 2007 12:03 pm |
|
|
I using a 128K PIC that has two ROM segments each 65K
I'm using very much modified bootloader from theByteFactory as a basis to develop my own. Size of bootloader is not an issue.
The bootloader #org statement is as follows
#define MAX_LOADABLE 0XFFFE
#org 0x0008, MAX_LOADABLE{}
Which puts the actual code at the top of the first segment.
I I try any higher org value the compile fails (real bad) and locks up.
I also tried V4.05 but it does hte same thing.
I remove fields from the hex file to reduce the size of this posting.
The removed portions are all FF
What do I need to do to put the bootloader at the top of memory ?
Thanks for any suggestions.
Hans W
:020000040000FA
:100000004BEF83F0FFFFFFFFFFFFFFFFFFFFFFFF4F
:10001000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0
removed as these locations are all FF
:10FE4000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC2
:10FE5000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFB2
:10FE6000FFFFF76A760FF66EFE0EF722000EF86EB1
:10FE70000900F5501200291973556D0FF76A900F9C
:10FE8000F66EFE0EF722000EF86E0900F550120015
:10FE900057616974696E6720666F722053796E636B
:10FEA0000000F76AB60FF66EFE0EF722000EF86E2F
:10FEB0000900F550120057616974696E6720666F1A
:10FEC0007220446174610000F76ADC0FF66EFE0E6A
:10FED000F722000EF86E0900F55012005570677297
:10FEE0006164652020202020202020200000F76A67
:10FEF000020FF66EFF0EF722000EF86E0900F550A5
:10FF000012002020205375636365737366756C203F
:10FF100020200000F76A280FF66EFF0EF722000E71
:10FF2000F86E0900F55012004661696C65643A5438
:10FF3000727920416761696E0000F76A4E0FF66EB4
:10FF4000FF0EF722000EF86E0900F5501200416412
:10FF500064726573732025582000F76A6E0FF66E81
:10FF6000FF0EF722000EF86E0900F55012004265F0
:10FF70006620255820255800F76A8C0FF66EFF0E74
:10FF8000F722000EF86E0900F55012004166742049
:10FF9000255820255800010EEA6E480EE96EEF50F4
:10FFA0000EE0050E016E006A002EFED7012EFBD773
:10FFB0006F0E006E002EFED70000EF2EF2D7000C61
:10FFC00001015239006E0F0E001600500038F00B80
:10FFD000006E0F0E85140010856E00008E80030EDB
:10FFE000006E002EFED78E900001000CFFFFFFFF79
:10FFF000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF11
:020000040001F9
:100000008E84F00E976E00008E80000000008550F8
:10001000F00B0101536F8E90000000000000000003
:1000200000008E80020E006E002EFED7000085506C
:10003000F00B526F523B0F0E52178E908E94000EA3
:10004000976E53515211016E00012FEF80F00101A4
:10005000516B8E928E84F00E976E0001D1D701C045
:1000600051F1010151BF2DEF80F0000E016E000132
:100070003BEF80F0ECD70152D8B441EF80F03AEF7B
:1000800080F001014F53D8B449EF80F08E824AEFDF
:1000900080F08E9200008E94000E976E00008E907D
:1000A00050C152F100018CDF130E006E002EFED7FE
:1000B0000000000001015039516FF00E511751C17D
:1000C00052F100017DDF000C959E8C9E0A0E01010D
:1000D000486F000160DF959E8C8E000E976E8E92A9
:1000E0008E94976E8E902D0E0101486F000153DFA4
:1000F000EB6BEB510208D8A08BEF80F0300E0101C2
:10010000526F00015DDF050E0101486F000143DF02
:10011000EB2B79EF80F0200E0101526F000150DFD0
:10012000EB6BEB510508D8A0B9EF80F0050E01018B
:10013000486F000130DFEB510208D8A4A8EF80F02F
:1001400001014F6B720E506F000194DFB6EF80F02B
:10015000036AEB51F2CFEEF0F29E83DEEEBFF28E39
:10016000EF6F01014F6B506F000184DFEB2B91EFBC
:1001700080F08E8201014F6B280E506F00017ADFF4
:10018000020E0101486F000106DF01014F6B290ECD
:10019000506F00016FDF020E0101486F0001FBDEAE
:1001A000C0EF83F0EAC0EAFFE9C0E9FF01014AC1FC
:1001B000EFFFE92AD8B4EA2AEF6A0001E92BD8B4A4
:1001C000EA2B000C01014C2DE8EF80F0ECEF80F001
:1001D000400E4D6FEDEF80F04D6B4B514D274D5163
:1001E00080094E6F4F6B506F000144DF5A0E006E56
:1001F000002EFED7000003EF81F001014B6B49C1D7
:100200004CF10001DFD701014A6B4A510F08D8A019
:100210001FEF81F04A514725016E000E4821036E01
:1002200001C0E9FFEA6EEFCF4BF1010E4F6F4BC1FA
:1002300050F100011FDF01014A2B05EF81F00001A1
:10024000000C9EAA21EF81F0ABCF16F0AECF01F0EB
:1002500016A22DEF81F0AB98AB880000000CFA6B72
:10026000FA510408D8A03DEF81F0F9519EA836EF6D
:1002700081F0AD6EFA2B30EF81F0000CFE51E96E8B
:10028000FFC0EAFF300EEF5C0101006F0001FEC00D
:10029000E9FFFFC0EAFFEF504008D8B054EF81F00B
:1002A000070E0101005F0001010EFE25E96E000E40
:1002B000FF21EA6E300EEF5C0101016F010E0001BB
:1002C000FE25E96E000EFF21EA6EEF504008D8B01F
:1002D0006DEF81F0070E0101015F01010039026F2E
:1002E000F00E021701510F0B0211016E0001000CFC
:1002F000010149BF90EF81F00F0E006E48390016E2
:100300000A0E005CD8B089EF81F0300E00268BEF2A
:1003100081F04951002600C04AF1000143DF01018C
:100320000F0E48170A0E485DD8B09AEF81F0300ED4
:100330009CEF81F0499F4951482748C14AF100018B
:1003400031DF000C48C101F047C100F00066012A0E
:100350000900F5CFEEFF002EA8EF81F0012EA8EFE7
:1003600081F0F86AA3EF82F0F250036EF29EA68E3F
:10037000A6840F01550EA76EAA0EA76EA6820000D6
:100380000350F2120001000CD08CA69CF650070B13
:10039000006EF80EF6160A0047C101F047C102F0E0
:1003A000080E006602260250070FF80B026EF65088
:1003B0000066E4EF81F0010F3F0BD8A4E4EF81F079
:1003C000A6880900D1DF0A000066F1EF81F0EECFC8
:1003D000F5FF0152D8B4F2EF81F00F000106F4EFFF
:1003E00081F000060B000C00070EF614070AD8B4C3
:1003F000BBDF022ED7EF81F0F86ABFEF82F0020E6A
:10040000E327000EE423FF6BFF510508D8A036EF69
:1004100083F0FBC0F8FFFAC0F7FFF9C0F6FF090050
:10042000F5500800F5CF03F0F86A0101006F03C032
:1004300001F10001EA6B050EE96F0101476B4751BD
:1004400000017BDD0101472B006E4A6F0001AADE2F
:10045000080E0101475DD8A41FEF82F0F9C048F1F2
:10046000370E496F000144DF200E01014A6F000181
:1004700099DE0101486B050E476F010E496F0001BF
:10048000BCDEEA6B050EE96F0101476B47510001C5
:1004900064DD0101472B006E4A6F000183DE040E0C
:1004A0000101475DD8A446EF82F000C148F1370E44
:1004B000496F00011DDF200E01014A6F000172DE4D
:1004C000FDC048F1370E0101496F000111DF010144
:1004D000486B050E476F400E496F00018EDE280EF7
:1004E0000101476FFA0E486F000155DD0101472FEA
:1004F000F9D70001F951C00B0101426FFAC043F175
:10050000FBC044F10001FCC045F101010001F951BB
:100510003F0B0101476F486B496B4A6BD8904A31DA
:10052000493148314731466F44C1F8FF43C1F7FFB5
:1005300042C1F6FF010EEA6E020EE96E486B400EF4
:10054000476F0001FFD6D89001014635036A020FBC
:10055000E96E010E0320EA6EFEC0ECFFED52FDC015
:10056000EFFF44C1F8FF43C1F7FF42C1F6FF010EA0
:10057000EA6E020EE96E400E476F000105D7FBC020
:10058000F8FFFAC0F7FFF9C0F6FF0900F5500800C0
:10059000F5CF03F0F86A0101006F03C001F100011B
:1005A000EA6B050EE96F0101476B47510001C5DC9D
:1005B0000101472B006E4A6F0001F4DD080E0101B6
:1005C000475DD8A4D5EF82F0F9C048F1370E496FE6
:1005D00000018EDE200E01014A6F0001E3DD010102
:1005E000486B050E476F010E496F000106DEEA6B8E
:1005F000050EE96F0101476B47510001BDDC0101A8
:10060000472B006E4A6F0001CDDD040E0101475DEE
:10061000D8A4FCEF82F000C148F1370E496F000109
:1006200067DE200E01014A6F0001BCDDFDC048F10C
:10063000370E0101496F00015BDE0101486B050EB9
:10064000476F400E496F0001D8DD280E0101476F4A
:10065000FA0E486F00019FDC0101472FF9D7000116
:10066000FD2BD8B4FE2BFF2B04EF82F0FD510101CE
:10067000005DD8A443EF83F00001FE510101015D4C
:10068000D8B447EF83F0000E016E49EF83F0010EFE
:10069000016E0001000CF86AD09EEA6AE96A060E53
:1006A000AF6E260EAC6E900EAB6EC150C00B0F0934
:1006B000C16E070EB46E166AE36BE46BE96BEA6B0E
:1006C000030E966E969E8D9E96948D9496968D961C
:1006D00096988D98969A8D9A969C8D8CF18ECB0ECD
:1006E000816E090E936E93988A88939A8A8AC15074
:1006F000C00B0C09C16EC080C092C084C09EC28075
:10070000170E926E929A899ABE0E946E949C8B9C50
:10071000836A200E956E95948C9495968C96959CF4
:100720008C9C959E8C8E000E976E8E86080E856E24
:10073000040E986E866A8F98949C8B9C959C8C9CDA
:10074000969C8D9C010EDE6F080EDD6F8C0E036A89
:1007500003C0DFF0DC6F800E016EEA6A180EE96EEE
:10076000EE6A012EB0EF83F0958A83BABAEF83F078
:10077000B4EF83F0E26B958083A01FEF84F0A4D4E4
:10078000EA6B050EE96FEB6BEB513EEC7FF0000975
:10079000D8B4D2EF83F0EB2B01014A6F000102DDE8
:1007A000C4EF83F00101486B050E476F010E496FDE
:1007B000000123DDE56B9EAA1BEF84F0036AE5517F
:1007C000180FE96E000E0320EA6EEACFEEF0E9CFD3
:1007D000EDF037DDEEC0EAFFEDC0E9FF01C0EFFF4D
:1007E000E52BE5510F08D8B01BEF84F0E66BE6511E
:1007F0000F08D8A01AEF84F0036AE651180FE96ECB
:10080000000E0320EA6EEF502B08D8A417EF84F0F7
:10081000010EE625036A180FE96E000E0320EA6E4A
:10082000EF503D08D8A417EF84F03D0EE26FE62BA1
:10083000F7EF83F0E56BE253D8B4DBEF83F0E251DE
:100840003D08D8B449EF84F0040EDC25EB6F000EB0
:10085000DD21EC6F000EDE21ED6F000EDF21EE6F6B
:10086000EDC0F8FFECC0F7FFEBC0F6FF0900F55054
:100870000800F5CF03F0F86AEC6F03C0EDF0EC2D43
:1008800049EF84F0ED53D8A449EF84F00000000054
:100890000000010EEB6FEA6B050EE96FF96BF95181
:1008A00051EC7FF00009D8B45DEF84F0F92B010121
:1008B0004A6F000177DC4FEF84F00101486B050EB1
:1008C000476F010E496F000198DCEC91EC83F86BE7
:1008D000F76BF66BF56BE76BECB125EF86F0ECA3ED
:1008E00025EF86F0800E016EEA6A180EE96EEE6A58
:1008F000012E77EF84F0176AE753D8A485EF84F0D0
:10090000780EF96FACDC88EF84F0720EF96FA7DC1B
:100910009EAA9EEF84F01750172A036A180FE96EFB
:10092000000E0320EA6EEACFFDF0E9CFFCF089DC8F
:10093000FDC0EAFFFCC0E9FF01C0EFFF010E175C3C
:10094000036A180FE96E000E0320EA6EEF500D08DF
:10095000D8A488EF84F0E56B1750E55DD8B0C3EFFD
:1009600084F0036AE551180FE96E000E0320EA6E69
:10097000EF503A08D8A4C0EF84F01706C3EF84F014
:10098000E52BACEF84F0E553D8B4F8EF84F0EF6BCF
:10099000EF517F08D8A0F8EF84F0036AEF51180FE9
:1009A000016E000E032203C0FAF0E551EF25036A41
:1009B000180FE96E000E0320EA6EEFCFFCF0FAC0CC
:1009C000EAFF01C0E9FFFCC0EFFF036AEF51180F17
:1009D000E96E000E0320EA6EEF500D08D8A4F5EF83
:1009E00084F0EFC017F0F8EF84F0EF2BC8EF84F03D
:1009F00018503A08D8B40DEF85F0EC93E72BE75187
:100A00000308D8B009EF85F0610EF96F28DC25EFF7
:100A100086F072EF84F023EF86F0E76BF16B010E46
:100A2000EF6F030E175CEF5DD8B028EF85F0036A17
:100A3000EF51180FF96F000E0320FA6FFF6FF9C026
:100A4000FEF01CDC0150F127020EEF2711EF85F0BC
:100A5000FF0ED880F155010FF16F020E175C036A8B
:100A6000180FFA6F000E0320FB6FFF6FFAC0FEF045
:100A700005DC01C0F2F0F251F15DD8B443EF85F02E
:100A8000EC9323EF86F0FF6B1F0EFE6F3EEC81F0C0
:100A900001C0F0F0F051010AD8B459EF85F0050A11
:100AA000D8B45CEF85F0040AD8B46DEF85F023EF7D
:100AB00086F0EC8123EF86F0FF6B210EFE6F3EEC9B
:100AC00081F001C0F8F0FF6B230EFE6F3EEC81F069
:100AD00001C0F7F0EC8323EF86F0FF6B190EFE6F79
:100AE0003EEC81F001C0EEF0FF6B1B0EFE6F3EECA2
:100AF00081F001C0F6F0FF6B1D0EFE6F3EEC81F041
:100B000001C0F5F0ED6B090EEF6F030E175CEF5DA2
:100B1000D8B021EF86F0ECA321EF86F0020EEF258E
:100B2000036A180FFA6F000E0320FB6FFF6FFAC005
:100B3000FEF03EEC81F001C0FBF0036AEF51180FAC
:100B4000FC6F000E0320FD6FFF6FFCC0FEF03EEC5B
:100B500081F0FBC0F4F001C0F3F0F853D8A4DBEF50
:100B600085F0F753D8A4DBEF85F0F653D8A4DBEF7C
:100B700085F0F5510208D8A0DBEF85F0D890F83168
:100B8000FD6FF731FC6FF631FB6FF531FA6FD890DE
:100B9000FA35006EFB35016EFC35FD35D80E0024AC
:100BA000E96E000E0120EA6EF4C0ECFFED52F3C0D6
:100BB000EFFF17EF86F0F853D8A406EF86F0F7534F
:100BC000D8A406EF86F0F651FE08D8A006EF86F00E
:100BD000D8A4F0EF85F0F5516008D8A006EF86F0B4
:100BE000F8C0FCF0F7C0FBF0F6C0FAF0F5C0F9F081
:100BF000F4C0FEF0F3C0FDF002DC01B003EF86F0BC
:100C0000EC9304EF86F0EC8317EF86F0F853D8A44A
:100C100016EF86F0F753D8A416EF86F0F6517F084A
:100C2000D8A016EF86F0EC9317EF86F0EC83020E57
:100C3000F527000EF623F723F823040EEF2785EFA0
:100C400085F023EF86F06CEF84F0EA6B050EE96F18
:100C5000F96BF95164EC7FF00009D8B438EF86F0F5
:100C6000F92B01014A6F0001D2EC80F029EF86F0E8
:100C70000101486B050E476F010E496F0001FDEC45
:100C800080F0ECA35DEF86F0730EF96F2FEC81F02E
:100C9000EA6B050EE96FF96BF95177EC7FF000090B
:100CA000D8B45BEF86F0F92B01014A6F0001D2EC5A
:100CB00080F04CEF86F074EF86F0660EF96F2FEC43
:100CC00081F0EA6B050EE96FF96BF9518AEC7FF060
:100CD0000009D8B474EF86F0F92B01014A6F0001C6
:100CE000D2EC80F065EF86F00101486B050E476F8E
:100CF000400E496F0001FDEC80F0000EECB3010ED8
:100D0000016E01B087EF86F0E09188EF86F0E08118
:100D1000E16BE1510208D8A0C7EF86F0E0A1C7EF70
:100D200086F0E151DC25EB6F000EDD21EC6F000E4B
:100D3000DE21ED6F000EDF21EE6FD890E131006E05
:100D4000D89000360050036AD80FE96E000E0320D9
:100D5000EA6EECCFF2F0ED52EFCFF1F0EEC0FCF026
:100D6000EDC0FBF0ECC0FAF0EBC0F9F0F2C0FEF021
:100D7000F1C0FDF0FFEC81F001B0C2EF86F0E09130
:100D8000C3EF86F0E081020EE12789EF86F0040EC2
:100D9000DC25EB6F000EDD21EC6F000EDE21ED6F28
:100DA000000EDF21EE6F000EE0B1010EEF6FEEC01E
:100DB000FCF0EDC0FBF0ECC0FAF0EBC0F9F0FE6B1C
:100DC000FD6FFFEC81F0020E0101486F0001CBECDA
:100DD0007FF0FF000300FFFFFFFFFFFFFFFFFFFFAC
:100DE000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF13
removed as these locations are all FF
:10FFB000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF51
:10FFC000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF41
:10FFD000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF31
:10FFE000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF21
:10FFF000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF11
:020000040020DA
:0800000000F003F001F008F02C
:0200000400F00A
:08000000FFFFFFFFFFFFFFFF00
removed as these locations are all FF
:0803F800FFFFFFFFFFFFFFFF05
:020000040030CA
:0E00000000060C0E83018100FFC0FFE0FF40F0
:00000001FF |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Sep 02, 2007 12:49 pm |
|
|
Quote: | I am using a 128K PIC that has two ROM segments each 65K.
I also tried V4.05. |
Post the PIC and the exact compiler version. |
|
|
Hans Wedemeyer
Joined: 15 Sep 2003 Posts: 226
|
Type and Version |
Posted: Sun Sep 02, 2007 1:48 pm |
|
|
PCM programmer wrote: | Quote: | I am using a 128K PIC that has two ROM segments each 65K.
I also tried V4.05. |
Post the PIC and the exact compiler version. |
Thanks for the reply:
PIC18F6720
I'm still using PCH V3.249 although I tried the latest PCH V4.053
V3.249 crashes real bad if the #org value is too high.
V4.053 does not crash, it just complains about invalid #org range
Hans W |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Sep 02, 2007 2:26 pm |
|
|
Can you explain more about exactly where you want each function to go ?
The following code compiles OK with PCH vs. 4.053. It puts main()
starting at 0x0008. It reserves 4 KB at the top of Flash Memory for
some other program (such as a bootloader).
Code: | #include <18F6720.h>
#fuses XT, NOWDT, PUT, BROWNOUT, NOLVP
#use delay(clock=4000000)
#org 0x1F000, 0x1FFFF
{}
//========================
void main()
{
while(1);
} |
|
|
|
Hans Wedemeyer
Joined: 15 Sep 2003 Posts: 226
|
Is that correct ? |
Posted: Sun Sep 02, 2007 3:24 pm |
|
|
PCM programmer wrote: | Can you explain more about exactly where you want each function to go ?
The following code compiles OK with PCH vs. 4.053. It puts main()
starting at 0x0008. It reserves 4 KB at the top of Flash Memory for
some other program (such as a bootloader).
Code: | #include <18F6720.h>
#fuses XT, NOWDT, PUT, BROWNOUT, NOLVP
#use delay(clock=4000000)
#org 0x1F000, 0x1FFFF
{}
//========================
void main()
{
while(1);
} |
|
This IS the bootloader not the program code.
Well this certainly puts the bootloader at one end of the memory. However I may be missing something here.
When I read things like "the bootloader resides" at the top of memory
I think of near the highest address.
#org 0x1F000, 0x1FFFF {}
Seems to put the bootloader at the bottom of memory ! or am I confused again ?
How do I put the loader into the 4K space you mentioned.
Here's the hex file:
020000040000FA
:040000002AEF84F06F
:020000040001F9
:10000000F76A140FF66E000EF722010EF86E090063
:10001000F5501200291973556D0FF76A2E0FF66E01
:10002000000EF722010EF86E0900F550120057611C
removed for brevity.
:10088000DB6F000ECFB1010EDBC0E9F0DAC0E8F09B
:10089000D9C0E7F0D8C0E6F0EB6BEA6F66DC020E79
:0808A000D86FE5D4FF0003004E
:020000040030CA
:0E00000000060C0E83018100FFC0FFE0FF40F0
:020000040020DA
:080000000FF001F00CF005F017
:00000001FF
;PIC18F6720
I'd prefer to leave the actual program code as is. theByteFactories bootloader implies it will use the program reset vector.
Hans W |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Sep 02, 2007 4:19 pm |
|
|
Quote: | This IS the bootloader not the program code. |
Now I understand . This code is actually downloadable from here:
http://www.thebytefactory.com/download.asp?file=codeloader_h.c
Once I got a look at it, I was able to come up with a solution, or at least
hopefully. I modified the 'MAX_LOADABLE' constant to consume all
of the first 64KB of flash and part of the next 64KB. Then I created
an #if-else block to check the range. If the MAX_LOADABLE value
extends into the 2nd 64KB, then I use two #org statements. The key
is that #org apparently only works for 64 KB max. If you need more,
then you have to use a 2nd #org statement.
Code: |
#if getenv("FUSE_SET:WDT")==TRUE
#define MAX_LOADABLE 0x16800
#else
#define MAX_LOADABLE 0x16820
#endif
#if MAX_LOADABLE > 0x0FFFF
#org 0x00008, 0x0FFFF {}
#org 0x10000, MAX_LOADABLE {}
#else
#org 0x00008, MAX_LOADABLE {}
#endif |
|
|
|
Hans Wedemeyer
Joined: 15 Sep 2003 Posts: 226
|
Almost there |
Posted: Sun Sep 02, 2007 5:06 pm |
|
|
PCM programmer wrote: | Quote: | This IS the bootloader not the program code. |
Now I understand . This code is actually downloadable from here:
http://www.thebytefactory.com/download.asp?file=codeloader_h.c
Once I got a look at it, I was able to come up with a solution, or at least
hopefully. I modified the 'MAX_LOADABLE' constant to consume all
of the first 64KB of flash and part of the next 64KB. Then I created
an #if-else block to check the range. If the MAX_LOADABLE value
extends into the 2nd 64KB, then I use two #org statements. The key
is that #org apparently only works for 64 KB max. If you need more,
then you have to use a 2nd #org statement.
Code: |
#if getenv("FUSE_SET:WDT")==TRUE
#define MAX_LOADABLE 0x16800
#else
#define MAX_LOADABLE 0x16820
#endif
#if MAX_LOADABLE > 0x0FFFF
#org 0x00008, 0x0FFFF {}
#org 0x10000, MAX_LOADABLE {}
#else
#org 0x00008, MAX_LOADABLE {}
#endif |
|
Thanks a lot I appreciate the help. It looks close and is certainly on the right track.
As you can see here the bootloader code ended up in the second segment
but not at the top.
So I tweaked the second $org and it moves it up some more but not all the way.
Code: |
#if getenv("FUSE_SET:WDT")==TRUE
#define MAX_LOADABLE 0x16800
#else
#define MAX_LOADABLE 0x16820
#endif
#if MAX_LOADABLE > 0x0FFFF
#org 0x00008, 0x0FFFF {}
#org 0x16800, MAX_LOADABLE {} // adjusted this value
#else
#org 0x00008, MAX_LOADABLE {}
#endif |
Are we looking at a third #org ?
Best regards
Hans W
.. with PCM Programmers original values
:020000040000FA
:1000000044EFB5F0FFFFFFFFFFFFFFFFFFFFFFFF24
:10001000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0
removed for brevity all locations FF
:10FFE000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF21
:10FFF000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF11
:020000040001F9
:10000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00
:10680000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF98
removed for brevity all locations FF
:10681000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF88
:10682000FFFFE56719EFB4F0E6671AEFB4F022EF67
:10683000B4F0E62BE4C0EEFFE52F1AEFB4F0E62F3C
:106840001AEFB4F0000C9EAA23EFB4F0ABCF05F022
removed for brevity
:10706000000ECC21D86F000ECD21D96F000ECE219D
:10707000DA6F000ECFB1010EDAC0E7F0D9C0E6F04A
:10708000D8C0E5F0D7C0E4F0E96BE86F7FDC020E12
:10709000D76FE3D4FF000300FFFFFFFFFFFFFFFFF9
:1070A000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0
:1070B000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE0
removed for brevity all locations FF
:10FFD000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF31
:10FFE000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF21
:10FFF000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF11
:020000040020DA
:080000000DF006F00FF006F010
:0200000400F00A
:08000000FFFFFFFFFFFFFFFF00
data eeprom
:0803F800FFFFFFFFFFFFFFFF05
:020000040030CA
:0E00000000060C0E83018100FFC0FFE0FF40F0
:00000001FF
;PIC18F6720 |
|
|
Hans Wedemeyer
Joined: 15 Sep 2003 Posts: 226
|
This seems to do the trick.. |
Posted: Sun Sep 02, 2007 5:15 pm |
|
|
The loader is reported as 2170 bytes
so I adjust as follows...
#define MAX_LOADABLE 0X1F780
:020000040001F9
:10FFC000000ECC21D86F000ECD21D96F000ECE21AE
:10FFD000DA6F000ECFB1010EDAC0E7F0D9C0E6F05B
:10FFE000D8C0E5F0D7C0E4F0E96BE86F7FDC020E23
:10FFF000D76FE3D4FF000300FFFFFFFFFFFFFFFF0A
:020000040020DA
:080000000FF006F00AF003F016
:0200000400F00A
:08000000FFFFFFFFFFFFFFFF00
Hans W |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Sep 02, 2007 5:27 pm |
|
|
The numbers that I used were copied from their sample code, which
they say are set to work with various compiler versions, etc.
You've adjusted them to a more accurate value for your app. |
|
|
Guest
|
Thanks again for the help |
Posted: Sun Sep 02, 2007 7:49 pm |
|
|
PCM programmer wrote: | The numbers that I used were copied from their sample code, which
they say are set to work with various compiler versions, etc.
You've adjusted them to a more accurate value for your app. |
PCM programmer just how or where did you get the info about using #org twice ? I would never have thought of that !
Anyway theByteFactory Bootloader needs a lot of work.
Next is handling 64 byte writes etc to speed up the load process.
With 120K of code to boot load this is going to take time. I may still do it from SD card directly and avoid the Bluetooth serial.
I have about 8-10K of ROM left so space is shoud not be an issue.
Hans W |
|
|
Rick Harris
Joined: 06 Aug 2007 Posts: 2
|
bootloader noob |
Posted: Sun Sep 02, 2007 9:11 pm |
|
|
Gents,
I'm impressed by the level of expertise available in this customer support forum, and have a quick question that's somewhat related to this thread.
I've been a C programmer for 20+ years, and am new to PIC programming. I have a PIC18F97J60 project that requires use of the Brush Electronics PIC18F97J60 Ethernet bootloader, and am so far unable to figure out how to actually load the bootloader into high memory. I'm using the CCS PCW v 4.46 Compiler, and any clues would be much appreciated.
This bootloader requires a GOTO to the bootloader in the first 4 instructions. Again, any clues on how to accomplish this would also be greatly appreciated.
Thanks! |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
Re: bootloader noob |
Posted: Fri Oct 24, 2008 11:51 pm |
|
|
Rick Harris wrote: | Gents,
I'm impressed by the level of expertise available in this customer support forum, and have a quick question that's somewhat related to this thread.
I've been a C programmer for 20+ years, and am new to PIC programming. I have a PIC18F97J60 project that requires use of the Brush Electronics PIC18F97J60 Ethernet bootloader, and am so far unable to figure out how to actually load the bootloader into high memory. I'm using the CCS PCW v 4.46 Compiler, and any clues would be much appreciated.
This bootloader requires a GOTO to the bootloader in the first 4 instructions. Again, any clues on how to accomplish this would also be greatly appreciated.
Thanks! |
Just found this old thread but thought I should answer for completeness.
The Brush Electronics PIC18F97J60 bootloader is a high memory bootloader. You do not need to do anything to load it high. If however you wanted to move it down to leave free memory above the bootloader, you do this by modifying the platform specific defines located at the start of the bootloader source. Not that the bootloader, as shipped, will not load user code above the base address of the bootloader. If you wanted the bootloader to do this you would have to modify the address validation logic to allow programming above the end of the bootloader.
If you use interrupts in your code then the CCS compiler will insert the goto instruction automatically. For applications that do not use interrupts or just to be consistant you can add the following directive
Code: | // reserve bootloader locations
#build(reset=0x00:0x07)
|
This dedicates the lower 8 bytes (four instructions) to the reset vector and forces a goto to be inserted. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
PIC24H
Joined: 02 Mar 2015 Posts: 19
|
|
Posted: Tue Mar 17, 2015 7:09 am |
|
|
I have the same problem. I'm using a PIC24HJ256GP610, CCS Compiler ver. 5.040 and a modified ex_pcd_bootloader.c
I want to save the space from 0x00000 till 0x103FF just for the bootloader. But as soon I include the header file of the bootloader into the application. The GOTO instruction is at address 0x0000 and not at addresss 0x10400 like it should be.
I have changed my bootloader hearder file code from
Code: | #define LOADER_SIZE 0x103FF
#define LOADER_END 0x103FF
#define LOADER_ADDR (LOADER_END - LOADER_SIZE)
.
.
.
#ifndef _bootloader
#ifdef BOOTLOADER_AT_START
#build (reset=LOADER_END+1,interrupt=LOADER_END+5)
#org 0, LOADER_END {}
#endif
#endif |
to
Code: | #define LOADER_SIZE 0x103FF
#define LOADER_END 0x103FF
#define LOADER_ADDR (LOADER_END - LOADER_SIZE)
#ifndef _bootloader
#ifdef BOOTLOADER_AT_START
#build (reset=LOADER_END+1,interrupt=LOADER_END+5)
#if LOADER_END > 0x0FFFF
#org 0x00000, 0x0FFFF {}
#org 0x10000, LOADER_END {}
#else
#org 0x00000, LOADER_END {}
#endif
#endif
#endif |
the c code of the bootloader has before its main this code
Code: | #org LOADER_END+1,LOADER_END+5
void application(void)
{
while(TRUE); // Dummy Applikation mit Endlosschleife
}
void main(void)
{
if(input(PUSH_BUTTON)) // Beim Reset den Butten gedrückt halten
{
....
}
application();
} |
It works fine the Bootloader size till 0xFBFF (application has then a GOTO at address 0xFC00) |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Tue Mar 17, 2015 8:11 am |
|
|
As I said in your other thread about this, have you tried with the #ORG definitions that PCM_programmer posted?. You have changed the start address of the #ORG's to 0, while he used 8, to leave space for the goto instruction that sits at the start of memory. This may be preventing the double #ORG from working. |
|
|
PIC24H
Joined: 02 Mar 2015 Posts: 19
|
|
Posted: Tue Mar 17, 2015 8:39 am |
|
|
Ttelmah wrote: | As I said in your other thread about this, have you tried with the #ORG definitions that PCM_programmer posted?. You have changed the start address of the #ORG's to 0, while he used 8, to leave space for the goto instruction that sits at the start of memory. This may be preventing the double #ORG from working. |
Yes, I have tried that, but as I said in the other thread the GOTO instruction in my application is still not there where it should be. The first address in that file was always the address of LOADER_END+1, but this was only up to a LOADER_END address of 0xFBFF. Beyond that the first adress starts again from 0x000. I have tried different addresses for LOADER_END (beyond 0xFFFF) and it always starts at 0x000 and never goes beyond 0xFC00.
Here is my actual code. With the use of 8 instead of 0. (Even with 0 it dont changes anything)
Code: | #define LOADER_PAGES 2 // Bootloader belegt 2 Seiten (2048 Adressen des Speichers (0x000-0x7FF)
#define BOOTLOADER_AT_START
#define LOADER_SIZE 0X103FF // Größe des Bootloaders in Adressen
#define LOADER_END 0x103FF // Letzte Speicheradresse des Bootloaderbereiches
#define LOADER_ADDR (LOADER_END - LOADER_SIZE) // Bottloader start bei 0 (bei 0x0 GOTO Anweisung zum Bootloader)
#ifndef _bootloader
#ifdef BOOTLOADER_AT_START
#build (reset=LOADER_END+1,interrupt=LOADER_END+5) // Offset der IVT etc.
#if LOADER_SIZE > 0x0FFFF
#org 0x00008, 0x0FFFF {}
#org 0x10000, LOADER_SIZE {}
#else
#org 0x00008, LOADER_SIZE {}
#endif
#endif
#endif |
The first address in the .lst file of the application is 0x400 (also for 0)
|
|
|
|