Hello,
I'm having trouble using readFlashDataPage in the flashloader with tools 13.2.
In init() it doesn't seem to work at all and always returns null; http://www.xcore.com/viewtopic.php?f=26&t=5053 suggested using the bootsize as the offset but that didn't work either.
http://www.xcore.com/viewtopic.php?p=20 ... b6e#p20090 says it doesn't work in init() and that it should instead be called in checkCandidateImageVersion(), however if i do this the loader hangs and no image is loaded at all.
So what is the correct way to use it, or is it not properly supported in 13.2?
Thanks,
Red.
Edit:
For reference I'm using a XS1-U12A <--> XS1-L6A
I see the same behaviour with tools 14.2 too.
readFlashDataPage in bootloader with tools 13.2
-
- Member++
- Posts: 20
- Joined: Wed Feb 04, 2015 10:14 am
-
- Active Member
- Posts: 39
- Joined: Wed Jul 20, 2016 9:15 am
Hello red,
one important thing is, that
Here is my code wich works on an XEF232 and 14.2.4
Maybe it will help you
Sebastian
one important thing is, that
reads with an absolute address.readFlashDataPage
Here is my code wich works on an XEF232 and 14.2.4
Maybe it will help you
Code: Select all
#include <xs1.h>
#include <platform.h>
/**************************************************************
if checkCandidateImageVersion reported no image of INTERREST,
the bootloader will load the factory image.
***************************************************************/
// we use 1.5Mb for images and rest for data + 1 Page of Data
#define BOOT_PARTITON_SIZE 0x181000
/*we could read the data partition of our flash drive*/
extern void * unsafe readFlashDataPage(unsigned addr);
/* Store the version of the image in memory that will potentially be booted */
int candidateImageVersion = -1;
unsigned candidateImageAddress;
int pin = 0;
/*Button for reading factory default */
//in port p_switch = on tile[0]: XS1_PORT_1P;
on tile[0]: in port p_switch = XS1_PORT_1P;
/* init is the first function called by the bootloader */
void init(void)
{
/*
data[0] = 0x12;
data[1] = 0x11;
data[2] = 0x11;
data[3] = 0x11;
fl_writeData(0, 4, data, preserve_data_buffer);
image = *(int*)readFlashDataPage(BOOT_PARTITON_SIZE); //1.5MByte Image storage
!!!!! image contains now 0x11111121; !!!!
*/
unsafe{
p_switch :> pin;
if(pin)
candidateImageVersion = 0; // load factory version;
else
candidateImageVersion = *(int * unsafe)readFlashDataPage(BOOT_PARTITON_SIZE); //1.5MByte Image storage
}
}
int checkCandidateImageVersion(int imageVersion)
{
if(candidateImageVersion > -1 && candidateImageVersion == imageVersion)
return 1;
else
return 0;
}
void recordCandidateImage(int imageVersion, unsigned imageAddress)
{
candidateImageVersion = imageVersion;
candidateImageAddress = imageAddress;
}
unsigned reportSelectedImage(void){
return candidateImageAddress;
}
Sebastian
-
- Member++
- Posts: 20
- Joined: Wed Feb 04, 2015 10:14 am
Hi Sebastian,
Thanks for the help but I was trying with the absolute address.
Here's the loader I'm currently trying to get to work;
and flashing the device with this command line:
Thanks for the help but I was trying with the absolute address.
Here's the loader I'm currently trying to get to work;
Code: Select all
#include <xs1.h>
#include <platform.h>
#include <stdio.h>
extern void * unsafe readFlashDataPage ( unsigned addr );
int keptVersion;
unsigned int keptAddress;
unsigned int bootFactory;
#define BOOT_PARTITON_SIZE 0x80000
void init( void ){
unsafe{
bootFactory = *(unsigned int * unsafe)readFlashDataPage (BOOT_PARTITON_SIZE);
}
keptAddress=0;
}
int checkCandidateImageVersion( int v ){
// this is a good version if we don't yet have an address
// or if we are not booting from factory and the version is
// greater than or equal to the kept version.
return ( keptAddress == 0 ) || ( !bootFactory && v >= keptVersion );
}
void recordCandidateImage( int v, unsigned int address ){
// we don't record the version if the kept address is still 0
// as this is assumed to be the factory image version
// and is therefore independent of the "upgrade" versions.
if ( keptAddress != 0 ) {
keptVersion = v;
}
// record the candidate address.
keptAddress = address;
}
unsigned int reportSelectedImage( void ){
// return what we found, should be at least one as the factory image
// will be recorded.
return keptAddress;
}
Code: Select all
xflash --loader src/loader.xc --spi-spec src/sst26vf064b.h --boot-partition-size 0x80000 --factory bin/Release/RRX_Factory.xe --upgrade 24 RRX_Main.024.xe --data src/data.dat