AnsweredAssumed Answered

How do I toggle ls1012a GPIO via bare-metal application?

Question asked by Tim Hammer on Aug 10, 2018
Latest reply on Aug 21, 2018 by Tim Hammer

I am attempting to bring up a custom board based on the ls1012a Freedom reference design. It seems that I have succeeded in connecting my CodeWarrior TAP and writing the RCW/PBI and U-Boot binary images via cwflash.py (there are no errors reported; implication is that RCW was written as I can now connect via the TAP with USE_SAFE_RCW = False). However, there is no indication on the UART that U-Boot is coming up.

 

I am able to run the Bare Metal "Hello World" example program through the CodeWarrior IDE and TAP- although when I switch the output to use the UART (.../lib/uart.specs vs. .../lib/simrdimon.specs) I do not get any output. I am able to get the output on my Freedom reference board as expected.

 

I figured I would fall back to some basic GPIO toggling to try and test out some basics. I thought I understood all the information I needed, but now am not so sure.

The hard-coded (SAFE) RCW has the field UART1_BASE (bits 368-369) set to 00 (I think; Table 4-11 in section 4.4.5.3 of the reference manual), so that means the pins should be accessible as GPIO1[0] and GPIO1[1].

The GPIO1 registers are at 0x0230_0000 according to the CCSR address map (Table 2-2 in section 2.3 of the reference manual) (the reference manual is a little confusing- on page 189 it says "table lists the block base address assigned to each block from the base of the 240 MB CCSR space"; this could mean that that address in the table is to be added to the CCSR base (0x0100_0000), but the first address in the table is 0x0100_0000, indicating it might already be an "absolute" address; besides, when I try using 0x0330_0000 for GPIO1 registers, the program throws an exception...).

 

I can set bits high at the direction register address (offset 0 (0x0230_0000)) and can see that my changes "stick" (i.e. looking at that address later I see the bits I set high are still high). However, when setting/clearing the corresponding bits at the data register (offset 8 (0x0230_0008)) I am not experiencing changes at the outputs.

I am unclear what is meant by the function description concerning reading the data register (in output mode read returns "data at pin"; in input mode read returns "state of the port"; reference manual section 20.5.4.4). Does this mean that in output mode the read will return the value last "written" to the bit whereas in input mode the read will return the value actually seen on the pin?

 

The GPIO1 (and GPIO2) descriptions in the CCSR table indicate that byte-swapping is required for these registers. I have tried working with GPIO1[0] and GPIO1[1] as bits 0 & 1 as well as bits 24 & 25. Both options behave as above. Am I not byte-swapping correctly? Should it be something other than bits 24 & 25?

 

 

Any thoughts or ideas would be greatly appreciated.

.Tim

Outcomes