• AVR Freaks

AnsweredHot!PIC32MZ Bootloader and FreeRTOS

Author
JCelectronique
New Member
  • Total Posts : 5
  • Reward points : 0
  • Joined: 2014/06/18 08:06:44
  • Location: France
  • Status: offline
2019/07/15 08:52:27 (permalink)
0

PIC32MZ Bootloader and FreeRTOS

Hi everybody
it's been several days that I'm looking for and I always stumble on the same thing, load an aplication with a UDP bootloader
 
i have made a custom board with a PIC32MZ2048EMF100 and a LAN8720, ATWINC1500 ....
 
I wrote a program that works very well on this board and uses FreeRTOS (because of ATWINC1500)
but now I've been using a bootloader and that's where I need your help
 
I tried the example programs basic and DMA_led_pattern to train me to bootloader with harmony on pic32 and all is working
I wrote a simple program of LAN8720 management and I generated with harmony a UDP bootloader, I also wrote an application (without FreeRTOS) with the linker generated by harmony and all is working
unified bootloader allows me to upload this application which starts without any problem
 
on the other hand when I add in my application FreeRTOS , the application is uploaded but after application bootloop continuously. the bootloader is still alive
 
I do not know where to look, maybe the linker file, the interrupt vector ... I hope to be understandable (little french lost)
 
Thanks for your help
#1
rjc101
Super Member
  • Total Posts : 133
  • Reward points : 0
  • Joined: 2016/07/08 14:56:34
  • Location: 0
  • Status: offline
Re: PIC32MZ Bootloader and FreeRTOS 2019/07/15 09:20:49 (permalink) ☼ Best Answerby JCelectronique 2019/07/16 08:31:40
5 (2)
I have discovered that when using FreeRTOS and any kind of boot loader on the EFM series, you need to have the ebase address in the linker file a multiple of 0x8000.
e.g.
PROVIDE(_ebase_address = 0x9D008000);

in the linker file of the main application or when you jump to the app it will simply stop or reboot.
#2
JCelectronique
New Member
  • Total Posts : 5
  • Reward points : 0
  • Joined: 2014/06/18 08:06:44
  • Location: France
  • Status: offline
Re: PIC32MZ Bootloader and FreeRTOS 2019/07/15 11:55:13 (permalink)
0
thank you for this track of research, I will try tomorrow
#3
NKurzman
A Guy on the Net
  • Total Posts : 18965
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: offline
Re: PIC32MZ Bootloader and FreeRTOS 2019/07/15 14:39:36 (permalink)
5 (1)
I wonder why that is, But thanks for the Information.
#4
JCelectronique
New Member
  • Total Posts : 5
  • Reward points : 0
  • Joined: 2014/06/18 08:06:44
  • Location: France
  • Status: offline
Re: PIC32MZ Bootloader and FreeRTOS 2019/07/16 08:30:38 (permalink)
5 (1)
actually, a huge thank you to rjc101. I just tested and the application with RTOS update well
if it can help other developer, the only change to be made to the linker file generated by harmony
From:
PROVIDE(_ebase_address = 0x9D001000);
To:
PROVIDE(_ebase_address = 0x9D008000);
 
thanks again
 
#5
Larry.Standage
Super Member
  • Total Posts : 927
  • Reward points : 0
  • Joined: 2011/12/30 09:50:47
  • Location: 0
  • Status: offline
Re: PIC32MZ Bootloader and FreeRTOS 2019/07/19 17:13:15 (permalink)
0
It must be something specific to FreeRTOS, because the EBASE register in the core starts at bit 12. Therefore, 0x9D001000 should work.
 
It might also have something to do with the startup code, especially FreeRTOS'. If the startup code (which would probably start at 0x9D000000) exceeds the 0x1000 length, then the IVT might not be valid. Looking at the mapping of the application with the ELFViewer plugin might help there.
#6
dapeters
New Member
  • Total Posts : 16
  • Reward points : 0
  • Joined: 2016/10/10 13:20:36
  • Location: 0
  • Status: offline
Re: PIC32MZ Bootloader and FreeRTOS 2019/10/23 13:51:02 (permalink)
0
I've been working with a bootloader/app for some time now using an older version of MPLAB (4.15).  I recently started playing around with MPLAB v.5.25 and trying out Harmony V3.  I created a simple FreeRTOS app that flashes some LEDs on the control with no problems.  Now, I'm trying to get the FreeRTOS app to load using the bootloader that I've been using for a while now.  I tried changing my linker script to PROVIDE(_ebase_address = 0x9D008000);, but that doesn't seem to work.  Is there any new information that anyone can supply on this issue?
#7
MantasP
New Member
  • Total Posts : 19
  • Reward points : 0
  • Joined: 2019/02/20 03:31:39
  • Location: 0
  • Status: offline
Re: PIC32MZ Bootloader and FreeRTOS 2020/09/30 08:30:42 (permalink)
0
dapeters, I had the same issue and the PROVIDE(_ebase_address = 0x9D008000). I wonder if you are having the same issue I had, can you enable uart and try print some statements in a loop to check if the code starts up and then crashes or does it just not run at all ?

Also has anyone figured out why the PROVIDE(_ebase_address = 0x9D008000) must be set to multiple of 0x8000?? I changed it to 0x4000 and my code ran for a few weeks but as I made changed I got the issue again where the code crashes once interrupt stuff is being done. I changed it to 0x8000 as suggested by @rjc101 
but I'm worried this is not a permanent fix?
 
 
 
 
dapeters
I've been working with a bootloader/app for some time now using an older version of MPLAB (4.15).  I recently started playing around with MPLAB v.5.25 and trying out Harmony V3.  I created a simple FreeRTOS app that flashes some LEDs on the control with no problems.  Now, I'm trying to get the FreeRTOS app to load using the bootloader that I've been using for a while now.  I tried changing my linker script to PROVIDE(_ebase_address = 0x9D008000);, but that doesn't seem to work.  Is there any new information that anyone can supply on this issue?




#8
dapeters
New Member
  • Total Posts : 16
  • Reward points : 0
  • Joined: 2016/10/10 13:20:36
  • Location: 0
  • Status: offline
Re: PIC32MZ Bootloader and FreeRTOS 2020/10/01 05:03:38 (permalink)
0
I did get it to work by changing it to 0x4000.  I haven't done anything with it now for several months due to other priorities.  When time allows I might get back into it again.
#9
cirilo.b
New Member
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2020/09/08 18:40:42
  • Location: 0
  • Status: offline
Re: PIC32MZ Bootloader and FreeRTOS 2020/10/01 18:29:40 (permalink)
0
The issue would be with how many interrupts RTOS is using, and therefore the offsets of the vectors from ebase, and how the MCU produces the vector address.  According to the MIPS documentation (*not* the Microchip docs): 
 
Vector  offsets > 0xFFF (vectored or EIC interrupts only), require  that EBase15..12 have zeros in each bit position less than or  equal to the most significant bit position of the vector offset.
 
So while ebase *must* be aligned to a 4096B boundary (simply because ebase will only store bits 29..12 of the specified address), there are other things to consider.  In particular ignore the Microchip docs statements about how the offset is added to ebase - that's nonsense; what happens is an offset is calculated and then combined with ebase using a bitwise OR operator. This is why things don't work as expected if ebase happens to have a bit set at a position equal to or less than the most significant bit of the calculated vector offset.
 
 
#10
Jump to:
© 2020 APG vNext Commercial Version 4.5