I am writing a bootloader for PIC32MX795F512L
Browsing the hex file generated by the MikroC for pic32 it looks like the flash addresses there are physical addresses.
Does the flash library accept physical addresses or should I somehow convert them to virtual addresses?
If I have to convert from physical address to virtual address this means that i should decide if the address should be translated into KSEG0
( by KSEG0=physical | 0x80000000) or to KSEG1 (by KSE1=physical | 0xA0000000).
In the case of translating from physical to virtual how should I decide the right KSEG segment?
Writing to flash and bootloader
Re: Writing to flash and bootloader
On another thought I think that it does not matter.
Actualy the data is stored in the physical flash. What matters is how the mcu is featcing the flash.
If the command is fetched via SEG0 or SEG1 determines if it is cached or not.
Am I right?
Actualy the data is stored in the physical flash. What matters is how the mcu is featcing the flash.
If the command is fetched via SEG0 or SEG1 determines if it is cached or not.
Am I right?
Re: Writing to flash and bootloader
Hi,
Please, take a look at the PIC32 Memory Organization chapter in the Help file.
You will find all necessary information regarding this.
Regards,
Filip.
Please, take a look at the PIC32 Memory Organization chapter in the Help file.
You will find all necessary information regarding this.
Regards,
Filip.
Re: Writing to flash and bootloader
Hi Filip,
Can you be more specific?
My question is not about the PIC32 memory map.
The question is about how to use the Flash_Write_Word function with the data in the hex file.
The addresses in the hex file are physical addresses while the Flash library is expecting virtual addresses.
One additional note about my bootloader application: the BL application will be located at the top of the program Flash memory
(Exactly as the USB HID Bootloader is placing the BL code).
So the question is:
what addresses should be passed to the Flash library given a physical address in the hex file?
Can you be more specific?
My question is not about the PIC32 memory map.
The question is about how to use the Flash_Write_Word function with the data in the hex file.
The addresses in the hex file are physical addresses while the Flash library is expecting virtual addresses.
One additional note about my bootloader application: the BL application will be located at the top of the program Flash memory
(Exactly as the USB HID Bootloader is placing the BL code).
So the question is:
what addresses should be passed to the Flash library given a physical address in the hex file?
Re: Writing to flash and bootloader
Hi,
Regarding the Flash library, you should pass it virtual address (both KSEG0 and KSEG1 are acceptable).
You can convert the physical address (like one from the HEX file) to the appropriate virtual (for Flash library utilization) using PA_TO_KVA0/PA_TO_KVA1 built-in routines.
Regards,
Filip.
Regarding the Flash library, you should pass it virtual address (both KSEG0 and KSEG1 are acceptable).
You can convert the physical address (like one from the HEX file) to the appropriate virtual (for Flash library utilization) using PA_TO_KVA0/PA_TO_KVA1 built-in routines.
Regards,
Filip.
Re: Writing to flash and bootloader
Thank you. That is exactly what I thought.