openrisc / newlib Goto Github PK
View Code? Open in Web Editor NEWnewlib OpenRISC development
License: GNU General Public License v2.0
newlib OpenRISC development
License: GNU General Public License v2.0
hi, Dear expert:
I follow the steps in https://openrisc.io/newlib/building.html to build my own or1k toolchains.
Now I am trying to use timerrelated functions in $OR1K_ELF/or1k-elf/include/or1k-support.h.
I first start with the example at line 446 in or1k-support.h
void tick_handler(void) {
// Make schedule decision
// and set new thread
or1k_timer_reset();
// End of exception, new thread will run
}
int main() {
// Configure operating system and start threads..
// Configure timer
or1k_timer_init(50);
or1k_timer_set_handler(&tick_handler);
or1k_timer_set_mode(SPR_TTMR_SR);
or1k_timer_enable();
// Schedule first thread and die..
}
But the example failed to pass compile because the define SPR_TTMR_SR is missed.
I try to get the answer from the define of or1k_timer_set_mode.
/*!
But I still not clear about the value of mode for simple run and continues run.
Please kindly help.
Thanks.
i did ./configure and make then make install its showing like this...>
make[1]: Entering directory '/home/mahadev/or1k/newlib'
/bin/bash ./mkinstalldirs /usr/local /usr/local
make[2]: Entering directory '/home/mahadev/or1k/newlib/etc'
make[2]: Nothing to be done for 'install'.
make[2]: Leaving directory '/home/mahadev/or1k/newlib/etc'
make[1]: Nothing to be done for 'install-target'.
make[1]: Leaving directory '/home/mahadev/or1k/newlib'
hi, Dear expert:
I am trying to use timer interrupt.
So first I need to set the timer period.
There are two functions for this purpose.
int or1k_timer_init (unsigned int hz)
void or1k_timer_set_period (uint32_t hz)
My question is why this function does not need the input of clock cycles?
if my clock freq is 100Mhz, I think the value should different to clock freq 50Hz.
Thanks.
This is just a minor race condition, but should be fixed: https://github.com/openrisc/newlib/blob/or1k/newlib/libc/sys/or1k/mlock.c#L88
hi, Dear experts:
I am trying to use void or1k_interrupt_enable(int line) to enable just one interrupt.
But it does not work.
I have to use void or1k_interrupts_enable(void) to enable all interrupts.
Looking forward to your reply.
Thanks.
We should not use the SPR_NPC here: https://github.com/openrisc/newlib/blob/or1k/libgloss/or1k/crt0.S#L153
Software should instead always use l.jal
and r9
, but here it is even simpler: Use the id
from the macro. Also needs change in the exception handler then (no address given anymore).
hi, Dear experts:
I tried to enable timer and interrupt at same time.
I add print in timer tick handler function. If I just enable the timer, I can see the print message.
But if I add or1k_interrupts_enable(); then the print message will not seen.
So is there any examples which support timer and interrupt at the same time?
Thanks.
Hi,
Following issue occurs on a mor1kx but I think it may be a toolchain problem.
When defining a byte array and casting parts of the byte array to a DWORD, the address of the first byte of the DWORD is probably not DWORD aligned (i.e. &byte_array[1] = 0x00000001 ). Normally, this is no problem and the DWORD pointer can be dereferenced correctly (i.e. p_u32 = (uint32_t *)&byte_array[1]; a=*p_u32;). When storing the DWORD pointer in a global structure, this does not work, the program simply hangs up when trying to dereference the pointer stored in the global struct. Please find below a program to show the problem. The program works fine compiled with standard gcc on a Linux machine but hangs up in Modelsim simulation when compiled with or1k-elf-gcc.
I am not sure to which branch of Openrisc development it belongs but it may be a toolchain problem as the dereferencing in general works when using the local struct. Also I am not sure if this is already fixed as I use an older (~1 year) version of mor1kx and toolchain.
Best regards,
Markus
#include <stdint.h>
#include <stdio.h>
//the structure contains a byte pointer and a DWORD pointer
typedef struct
{
uint8_t * p_struct_u8;
uint32_t * p_struct_u32;
} struct_pointers;
//the structure itself as global variable; does not work!
struct_pointers sp; //comment this line and uncomment the local struct definition to work correctly
int main(int argc, char *argv[])
{
//10 byte array
uint8_t v_array_u8 [10] = {1,2,3,4,5,6,7,8,9,10};
//pointer to byte
uint8_t * p_u8;
//pointer to DWORD
uint32_t * p_u32;
// struct_pointers sp; //the structure as local variable does work; uncomment this line and comment the global struct definition to work correctly
//point to first byte (DWORD aligned pointer address)
p_u8 = &v_array_u8[0];
p_u32 = (uint32_t *)&v_array_u8[0];
//store the pointers in the struct
sp.p_struct_u8 = p_u8;
sp.p_struct_u32 = p_u32;
printf("Addresses of pointers without struct DWORD aligned \n\r");
printf("p8: %#010x \n\r", (unsigned int)p_u8);
printf("p32: %#010x \n\r", (unsigned int)p_u32);
printf("Dereferenced pointers without struct \n\r");
printf("*p8: %#010x \n\r", (unsigned int)*p_u8);
printf("*p32: %#010x \n\r", (unsigned int)*p_u32);
printf("Addresses of pointers stored in struct DWORD aligned\n\r");
printf("sp8: %#010x \n\r", (unsigned int)sp.p_struct_u8);
printf("sp32: %#010x \n\r", (unsigned int)sp.p_struct_u32);
printf("Dereferenced pointers from struct \n\r");
printf("*sp8: %#010x \n\r", (unsigned int)*sp.p_struct_u8);
printf("*sp32: %#010x \n\r", (unsigned int)*sp.p_struct_u32);
//point to second byte (not DWORD aligned pointer address)
p_u8 = &v_array_u8[1];
p_u32 = (uint32_t *)&v_array_u8[1];
//store the pointers in the struct
sp.p_struct_u8 = p_u8;
sp.p_struct_u32 = p_u32;
printf("Addresses of pointers without struct not DWORD aligned \n\r");
printf("p8: %#010x \n\r", (unsigned int)p_u8);
printf("p32: %#010x \n\r", (unsigned int)p_u32);
printf("Dereferenced pointers without struct \n\r");
printf("*p8: %#010x \n\r", (unsigned int)*p_u8);
printf("*p32: %#010x \n\r", (unsigned int)*p_u32);
printf("Addresses of pointers stored in struct not DWORD aligned\n\r");
printf("sp8: %#010x \n\r", (unsigned int)sp.p_struct_u8);
printf("sp32: %#010x \n\r", (unsigned int)sp.p_struct_u32);
printf("Dereferenced pointers from struct \n\r");
printf("*sp8: %#010x \n\r", (unsigned int)*sp.p_struct_u8);
printf("*sp32: %#010x \n\r", (unsigned int)*sp.p_struct_u32); //hangs up here when dereferencing non DWORD aligned address
printf("Successfully finished! \n\r");
while(1) {};
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.