Kyu is set up in terms of a board and an architecture. The architecture for Zynq will be "ARM", which is already finished thanks for work on the BBB and Orange Pi. So we just need to set up a Zynq board. I could set up Antminer and Ebaz and other specific boards, but that would generated endless duplication and clutter. I will just differentiate between the Antminer and Ebaz by using a handful of definitions in the board.h file.
In essence, the game will be to see how far I can get porting Kyu by simple supplying a serial console driver. I will probably want and need a timer driver also almost immediately, but we will cross that bridge when we get to it.
To get started, I will need to create a zynq directory and add a zynq target entry to the config script. I will also need to add these files in the "configs" directory:
./config zynqWhich is sort of a milestone.
But what about the contents of these files? I compare the bbb and orange_pi versions of the two Makefiles to get a handle on what may be of interest there. The BBB is a cortex-a8 and the orange_pi is a cortex-a7, so that difference is in Makefile.inc. The top Makefile has a bunch of orange_pi cruft that I just delete.
The zynq.lds file needs a different base address for the text area, namely 0x20000000 -- that is the only change.
I have decided that in the case of WANT_NET, this ought to be in board/board.h rather than the central kyu.h since it varies from board to board. This is some kyu housekeeping that I will tackle right now.
At this point, the file board.h is just a copy of the orange_pi file. I make two changes:
Then I try running make to build kyu, just to see what functions are missing. Here is the list:
board_init board_hardware_init board_mmu_init board_ram_init core_stacks board_core_startup board_new_core board_early_putchar board_timer_init board_timer_rate_set board_get_cpu_mhz intcon_ena intcon_dis intcon_irqwho serial_init serial_getc serial_putc serial_puts board_net_init board_net_debug board_net_send board_net_show get_board_net_addr reset_cpu delay_us (delay_ms) gpio_test test_led_on test_led_offThat is more than I expected, but it certainly serves to guide the rest of this work. The network things will end up being stubs (for now) in board.c. The two test calls should be conditional in test_io.c and I make it so.
After adding board.c (copied from orange_pi and worked on), we reduce the above to:
console_use_ints serial_init serial_getc serial_putc serial_putsSo now we just need to add a serial (uart) driver -- with some attention to making it interrupt driven. We have already written a bare metal serial driver and can use that as a starting point. I copy it (it is extremely basic), and modify a few things and I get my first clean link. Not bad for a mornings work.
Filename 'bitcoin.bin'. Load address: 0x20000000 Bytes transferred = 210848 (337a0 hex) ## Starting application at 0x20000000 ... TJT in mmu_set_ttbr, page table: 20038000 set TTBCR to 0, read back: 00000000 set TTBR0 to 2003800b, read back: 2003800b set TTBR1 to 2003800b, read back: 2003800b set DACR to ffffffff, read back: ffffffff TJT mmu_set_ttbr finishedAnd that is it. No more output and no response to characters typed.
Tom's Computer Info / tom@mmto.org