Forum Discussion
Altera_Forum
Honored Contributor
19 years agoThank you a lot for the advice, this was something i didnt know yet
So, I just tried out the compiler switches with my test program and -mbypass-cache and -mno-cache-volatile made the pointer operations work like io-instructions. For unknown reason, -mno-bypass-cache did not success. But within my test-program, it works. But when adding this options to compiler options for building redboot, * i was really wondering * it did not work... http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/sad.gif I tried to modify the flash_driver function flash_query(void* data) to make sure and replaced all direct io operations... i thought, this should work for sure, but i don't know why the hell, but it doesn't http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/mad.gif...
// Marek: made some helper macros# if (_16AS8 == 0)# define FIO_WR(ADDR, DATA) HAL_WRITE_UINT8(CYGNUM_FLASH_BASE + ADDR, DATA)# define FIO_RD(ADDR, VALUE) HAL_READ_UINT8(CYGNUM_FLASH_BASE + ADDR, VALUE)# else# define FIO_WR(ADDR, DATA) HAL_WRITE_UINT16(CYGNUM_FLASH_BASE + ADDR, DATA)# define FIO_RD(ADDR, VALUE) HAL_READ_UINT16(CYGNUM_FLASH_BASE + ADDR, VALUE)# endif
# define FIO_S1_WR( DATA ) FIO_WR( FLASH_Setup_Addr1 , DATA)# define FIO_S2_WR( DATA ) FIO_WR( FLASH_Setup_Addr2 , DATA)
...
void
flash_query(void* data)
{
//volatile flash_data_t *ROM;
//volatile flash_data_t *f_s1, *f_s2;
flash_data_t* id = (flash_data_t*) data;
flash_data_t w,w2;
long timeout = CYGNUM_FLASH_TIMEOUT_QUERY;
//ROM = (flash_data_t*) CYGNUM_FLASH_BASE;
//f_s1 = FLASH_P2V(ROM+FLASH_Setup_Addr1);
//f_s2 = FLASH_P2V(ROM+FLASH_Setup_Addr2);
// *f_s1 = FLASH_Reset;
FIO_S1_WR(FLASH_Reset);
// w = *(FLASH_P2V(ROM));
FIO_RD(0, w);
// *f_s1 = FLASH_Setup_Code1;
FIO_S1_WR(FLASH_Setup_Code1);
// *f_s2 = FLASH_Setup_Code2;
FIO_S2_WR(FLASH_Setup_Code2);
// *f_s1 = FLASH_Read_ID;
FIO_S1_WR(FLASH_Read_ID);
id = -1;
id = -1;
// Manufacturers' code
// id = *(FLASH_P2V(ROM+FLASH_VendorID_Addr));
FIO_RD(FLASH_VendorID_Addr, id);
// Part number
// id = *(FLASH_P2V(ROM+FLASH_DeviceID_Addr));
FIO_RD(FLASH_DeviceID_Addr, id);
// id = *(FLASH_P2V(ROM+FLASH_DeviceID_Addr2));
FIO_RD(FLASH_DeviceID_Addr2, id);
// id = *(FLASH_P2V(ROM+FLASH_DeviceID_Addr3));
FIO_RD(FLASH_DeviceID_Addr3, id);
// *(FLASH_P2V(ROM)) = FLASH_Reset;
FIO_WR(0, FLASH_Reset);
// Stall, waiting for flash to return to read mode.
FIO_RD(0,w2);
while ((--timeout != 0) && (w != w2/* *(FLASH_P2V(ROM))*/))
{
FIO_RD(0,w2);
};
} Did I something wrong?? The nearly same code works in my testing program ... Note: I put a look into the source of ecos 2.01 and found that someone already tried to fix that problem by using hal_dcache_xxxx in a function that wrapp's flash_query. But this depends on that the prozessor is able to switch dcache'ing on/off, which the NIOS prozessor isn't able to. So these Macros actually do nothing when build for NIOS. void
flash_query(void* data)
{
int cache_on;
HAL_DCACHE_IS_ENABLED(cache_on);
if (cache_on) {
HAL_DCACHE_SYNC();
HAL_DCACHE_DISABLE();
}
_flash_query(data);
if (cache_on) {
HAL_DCACHE_ENABLE();
}
} I currently give up trying to build redboot and wonder, if all people have such problems, when trying nios with redboot or if i'm just an anomalie... Regards, Marek PS: Sorry for posting much code, i hope it helps more than ti does struggeling you