Writing to flash and bootloader

General discussion on mikroBasic PRO for PIC32.
Post Reply
Author
Message
hooper
Posts: 143
Joined: 23 Oct 2009 08:51

Writing to flash and bootloader

#1 Post by hooper » 06 Jan 2017 00:16

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?

hooper
Posts: 143
Joined: 23 Oct 2009 08:51

Re: Writing to flash and bootloader

#2 Post by hooper » 06 Jan 2017 07:46

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?

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Writing to flash and bootloader

#3 Post by filip » 06 Jan 2017 11:20

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.

hooper
Posts: 143
Joined: 23 Oct 2009 08:51

Re: Writing to flash and bootloader

#4 Post by hooper » 06 Jan 2017 14:38

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?

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Writing to flash and bootloader

#5 Post by filip » 09 Jan 2017 14:34

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.

hooper
Posts: 143
Joined: 23 Oct 2009 08:51

Re: Writing to flash and bootloader

#6 Post by hooper » 09 Jan 2017 17:33

Thank you. That is exactly what I thought.

Post Reply

Return to “mikroBasic PRO for PIC32 General”