Hi OSDevers,
I am following this article to get a small binary to run in my ARM board, which explains how to print a character to the serial console.
Although the tutorial is for the beagleboard, I have a different board (S3C6410 from samsung) and according to the S3C6410 manaul the UART registers are properly programmed.
Whenever I run the binary only one character gets printed on screen and after that am getting data abort or the board resets.
Basically I load the program to RAM from uboot using ymodem transfer.
I then run it by using the "go" command in uboot passing the address in RAM where I have copied.
Here is my program the linker script and the console log of the results.
I have also verified that the binary transfer is proper by dumping it with mw uboot command.
I feel am doing something wrong but can't find what it is.
Could someone point me to what could be the possible problems?
Thanks in advance.
Regards,
Sundar
ARM - printing to serial console fails
- thepowersgang
- Member
- Posts: 734
- Joined: Tue Dec 25, 2007 6:03 am
- Libera.chat IRC: thePowersGang
- Location: Perth, Western Australia
- Contact:
Re: ARM - printing to serial console fails
I haven't done any work with this SoC, but I can offer some suggestions.
1. Make sure you are waiting for the UART FIFO to have space before writing.
2a. Are you sure you're getting a data fault?
2b. If the board resets, how does that happen? Did you update the fault vectors when loading?
3. Try to pare down the code to just the serial output, and see if you can get multiple characters printing, if that doesn't work, feel free to post the code (if it's longer than a page onscreen, you haven't trimmed it down enough)
1. Make sure you are waiting for the UART FIFO to have space before writing.
2a. Are you sure you're getting a data fault?
2b. If the board resets, how does that happen? Did you update the fault vectors when loading?
3. Try to pare down the code to just the serial output, and see if you can get multiple characters printing, if that doesn't work, feel free to post the code (if it's longer than a page onscreen, you haven't trimmed it down enough)
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
Re: ARM - printing to serial console fails
Looks like paste of code (http://pastebin.com/gVEJaJBZ) is incomplete.
Re: ARM - printing to serial console fails
Hi guys,
Well it gave me different results a few times.
First thing is that it is able to print the character 'h' just after a garbled character.
Then it goes for a reset as in the log. When i tried to print character by character instead of a string literal, i got only the last character on console.,
meaning that the cursor wasn't moving to the next position after printing one.
Sometimes i got a data abort. It is weird that only if i read the TX/RX status register it aborts. Other registers are just fine to read or write.
But if i read it from uboot using mw.l command it displays the result.
powersgang, i haven't done anything to the interrupt vectors. Am actually checking the status of the FIFO before writing.
berkus, thanks i'll check that out and see if it can help me find the issue i've got.
nable, well thats the whole of the code. i am returning to uboot after printing the string. (well it supposed to..)
I'll check again and post guys. Thanks all!
Regards,
Sundar
Well it gave me different results a few times.
First thing is that it is able to print the character 'h' just after a garbled character.
Then it goes for a reset as in the log. When i tried to print character by character instead of a string literal, i got only the last character on console.,
meaning that the cursor wasn't moving to the next position after printing one.
Sometimes i got a data abort. It is weird that only if i read the TX/RX status register it aborts. Other registers are just fine to read or write.
But if i read it from uboot using mw.l command it displays the result.
powersgang, i haven't done anything to the interrupt vectors. Am actually checking the status of the FIFO before writing.
berkus, thanks i'll check that out and see if it can help me find the issue i've got.
nable, well thats the whole of the code. i am returning to uboot after printing the string. (well it supposed to..)
I'll check again and post guys. Thanks all!
Regards,
Sundar
Re: ARM - printing to serial console fails
Hi guys,
I have managed to find out the issue with the UART configuration.
I had mistakenly switched off the FIFO mode which defaulted to interrupt
Mode. Now that I've got serial console working I want to try interrupts.
I have installed my handler by replacing the one used by uboot which was a stub.
(well mine too just prints that an interrupt has been raised.)
The thing is even after unmasking IRQ and FIQ I couldn't get the handler called.
I had the UART configured in interrupt mode to trigger interrupts as I type in something in the console.
Then I enabled the vectored interrupt controller (PL192) in CP15 system control register (VE bit). I had to configure the interrupt type as IRQ and enabled all the interrupts. The vector address is also set to the handler.
But still nothing could trigger my handler. I've checked my handler is correctly installed and it follows the right procedure as per the requirements of ARM architecture.
I used an LDR PC, <offset within 0xfff>
And in the offset (0x1c) from the vector table (0x18 for IRQ) is where I've put my handler's address.
Could anyone point to me what could be wrong or anything that I am missing.
By the way, I start my binary from uboot using go <address> command.
I haven't tried bootm as I thought the result would be same.
Thanks in advance for any help!
Regards,
Sundar
I have managed to find out the issue with the UART configuration.
I had mistakenly switched off the FIFO mode which defaulted to interrupt
Mode. Now that I've got serial console working I want to try interrupts.
I have installed my handler by replacing the one used by uboot which was a stub.
(well mine too just prints that an interrupt has been raised.)
The thing is even after unmasking IRQ and FIQ I couldn't get the handler called.
I had the UART configured in interrupt mode to trigger interrupts as I type in something in the console.
Then I enabled the vectored interrupt controller (PL192) in CP15 system control register (VE bit). I had to configure the interrupt type as IRQ and enabled all the interrupts. The vector address is also set to the handler.
But still nothing could trigger my handler. I've checked my handler is correctly installed and it follows the right procedure as per the requirements of ARM architecture.
I used an LDR PC, <offset within 0xfff>
And in the offset (0x1c) from the vector table (0x18 for IRQ) is where I've put my handler's address.
Could anyone point to me what could be wrong or anything that I am missing.
By the way, I start my binary from uboot using go <address> command.
I haven't tried bootm as I thought the result would be same.
Thanks in advance for any help!
Regards,
Sundar
- Owen
- Member
- Posts: 1700
- Joined: Fri Jun 13, 2008 3:21 pm
- Location: Cambridge, United Kingdom
- Contact:
Re: ARM - printing to serial console fails
VE does not enable the VIC: It enables auto-vectoring of interrupts in an implementation-defined way. The VIC is not controlled by CP15.sundar wrote:Then I enabled the vectored interrupt controller (PL192) in CP15 system control register (VE bit). I had to configure the interrupt type as IRQ and enabled all the interrupts. The vector address is also set to the handler.
Re: ARM - printing to serial console fails
Hi Owen,
Well, thanks for pointing it out. I probably have misunderstood the meaning of the VE bit in SCTRL of CP15., that i read from ARM's PL192 document
But before that i tried without enabling VE bit, but then too interrupts were not triggered.
- got the IRQ handler installed to the vector table
- configured the VIC properly
- unmasked the IRQ and even the FIQ in CPSR
No interrupt got triggered.
Is there any other thing related to interrupts that i should look for?
Thanks,
Sundar
Well, thanks for pointing it out. I probably have misunderstood the meaning of the VE bit in SCTRL of CP15., that i read from ARM's PL192 document
But before that i tried without enabling VE bit, but then too interrupts were not triggered.
- got the IRQ handler installed to the vector table
- configured the VIC properly
- unmasked the IRQ and even the FIQ in CPSR
No interrupt got triggered.
Is there any other thing related to interrupts that i should look for?
Thanks,
Sundar
Re: ARM - printing to serial console fails
Hi guys,
Finally I got the interrupts working.
Thanks to Owen and geist who pointed out my mistakes in configuring the VIC and IRQ handler.
I had issues in setting up the IRQ stack, switching processor mode and in saving the context when an IRQ fires.
So now with interrupts working, I'll try some timers, LEDs and buttons next.
Thank you very much for the help guys!
Regards,
Sundar
Finally I got the interrupts working.
Thanks to Owen and geist who pointed out my mistakes in configuring the VIC and IRQ handler.
I had issues in setting up the IRQ stack, switching processor mode and in saving the context when an IRQ fires.
So now with interrupts working, I'll try some timers, LEDs and buttons next.
Thank you very much for the help guys!
Regards,
Sundar