sergev / LiteBSD

Variant of 4.4BSD Unix for microcontrollers
Other
307 stars 36 forks source link

Majenko SDZL board equivalent #69

Open i4cy opened 6 years ago

i4cy commented 6 years ago

Unfortunately the Majenko SDZL board (so far) is not available, either as a design or a premade board. So I am designing an equivalent SDZL board, with the intention that it will work with the pre built SDZL binaries. Like the SDZL board this board will be based around the 64pin PIC32MZ2048ECM064, and expected to support the same peripherals, and so have the same assigned microcontroller pins. The SDZL wiki offers most config and hardware information, as does the LiteBSD startup screen.

Copyright (c) 1982, 1986, 1989, 1991, 1993
        The Regents of the University of California.  All rights reserved.

    4.4BSD-Lite build 1 compiled 2015-08-27
        sergev@ubuntu-sergev:LiteBSD/sys/compile/Whitecat.pic32
    cpu: PIC32MZ2048ECM064 rev A5, 200 MHz
    oscillator: system PLL div 1:6 mult x50
    cache: 16/4 kbytes
    real mem = 512 kbytes
    avail mem = 344 kbytes
    using 18 buffers containing 73728 bytes of memory
    spi2 at pins sdi=G7/sdo=G8/sck=G6
    en0 at interrupt 153, MAC address d8:80:39:13:d3:67
    en0: <SMSC LAN8720A> at address 1
    uart1 at pins rx=F4/tx=F5, interrupts 112/113/114, console
    uart2 at pins rx=B7/tx=B6, interrupts 145/146/147
    uart3 at pins rx=C13/tx=C14, interrupts 157/158/159
    uart4 at pins rx=D5/tx=D4, interrupts 170/171/172
    sd0 at port spi2, pin cs=G9
    gpio1 at portB, pins ------------iiii
    sd0: type II, size 1982464 kbytes, speed 16 Mbit/sec
    sd0a: partition type b7, sector 2, size 204800 kbytes
    sd0b: partition type b8, sector 409602, size 32768 kbytes
    sd0c: partition type b7, sector 475138, size 102400 kbytes
    WARNING: preposterous clock chip time -- CHECK AND RESET THE DATE!

But there are some questions that need clarifying, which hopefully someone can answer.

  1. PLL div 1:6 is printed out on the startup screen, so I assume the microcontroller uses a 8MHz crystal?

  2. Unlike the SDZL board, this board will obviously not have a bootloader. So I intend to program the microcontroller directly using the ICSP with one of the Microchip programming tools (e.g. Pickit3 or ICD3) and the vmunix.hex firmware. Will this method work?

  3. I was expecting to find the microcontroller routines amongst the ported source code on the github repository, but I couldn't find any microcontroller specific code. If it is somewhere there, where should I look?

Thanks in advance. BTW what an interesting project, and I tip my hat to Serge for his great work!

sergev commented 6 years ago

Hi i4cy,

  1. The board uses 24MHz oscillator. PLL divides it by 6 and multiplies by 50, resulting in 24 / 6 * 50 = 200MHz.

  2. Yes, programming by pickit3 or icd3 is OK.

  3. PIC32-specific routines are located here: https://github.com/sergev/LiteBSD/tree/master/sys/mips

Regards, --Serge

i4cy commented 6 years ago

Hello Serge,

Many thanks for your prompt reply to the questions. Ok, 24MHz oscillator (not crystal), and this is also confirmed in the source code that you pointed me to. Once I've built the board, if it works I'll keep you posted.

Kind regards, Guy (i4cy)

majenkotech commented 6 years ago

Now we have a working chipKIT MZ USB bootloader available I believe @EmbeddedMan is going to resurrect the development of the Fubarino SDZ, which is like my SDZL.

EmbeddedMan commented 6 years ago

That is correct. One of the next upcoming projects will be to update the Fubarino SDZ board to have a better power supply section, then build some protos and put Majeno's MZ bootloader on there, then add that new board to chipKIT core. Not sure on the exact timeframe - but I'm targeting having that all done in the next 3 months.

i4cy commented 6 years ago

As intended, I have now built the "equivalent" Majenko SDZL board, but unfortunately I'm unable to get BSDLite working on it.

As this board is not trivial to construct I first suspected the board itself, so I created a simple Microchip Harmony project to toggle a GPIO pin at a specific frequency. After programming the board the test program works as expected, so I am pretty confident that the 24MHz external clock and PIC32MZ chip etc are working ok.

Using Microchip MPLAB IPE v4.00 and ICD3 I managed to program the board using the vmunix.hex (litebsd-sdzl-2017-05-16) file. However I noticed that the CONFIG settings were not correct after loading the HEX file into IPE. I assume that the vmunix.hex file is intended to only work with pic32prog and not with Microchip programmers. The source code machdep.c file contains CONFIG settings for the other supported boards, but it seems not the SDZL board. Anyway the CONFIG settings were set in IPE to something more meaningful (see attached config.txt) and the board reprogrammed.

After powering up or resetting I would expect at least some of the PIC pins to change state from high impedance, especially the UART or SD card pins. Due to the lack of PIC I/O activity I assume that ICD3 has not loaded vmunix.hex correctly. Perhaps I should be using pic32prog to load vmunix.hex instead of ICD3.

  1. What tool is used to initially program the bootloader code into the SDZL board?
  2. Is there a separate bootloader hex file, if so is it available?
  3. Without a SDZL schematic diagram to hand, the "equivalent" board may be using the wrong I/O pins. Please refer to attached schematic to confirm?
  4. What PIC pin is the LED connected to?

Many thanks.

config.txt img_6805 unix_mz.pdf

sergev commented 6 years ago
  1. LiteBSD on SDZL board is configured for chipkit serial bootloader. Here is the hex file: https://raw.githubusercontent.com/UECIDE/pic32/master/boards/Majenko%20Technologies/sdzl/bootloader.hex It's a serial bootloader (not USB), configured for pins RB6 and RB7 as RXD and TXD. Any 3.3v TTL-to-USB adapter should work, like: https://raw.githubusercontent.com/wiki/sergev/LiteBSD/majenko-sdzl-with-usb-serial.jpg

  2. To program the bootloader to the board, I use pickit2 and pic32prog. Pickit3 and mdb.sh utility from MPLABX should work as well. When the bootloader is installed, pic32prog can upload the LiteBSD kernel via the serial port. No need for pickit2 or pickit3.

  3. I/O pins on attached schematic look correct. Ethernet port is not currently configured in LiteBSD for SDZL board.

  4. LED on SDZL board is connected to pin RE7.

i4cy commented 6 years ago

Hello Serge,

Just to let you know I have finally got the board working. With your help and guidance, in the end I used Microchip IPE and ICD3 to program the bootloader, then used your pic32prog program via the serial port to load the BSDLite kernel. The LED also works.

It is absolutely amazing work having ported BSD onto a PIC albeit at the top of the range that Microchip have to offer. I've migrated code bases over in the past and know how much work can be involved. After I have had fun playing around with BSDLite, I suppose my next project will be to get the Ethernet port wired up and configured.

Thanks again for all your help.

Best wishes, Guy

i4cy commented 6 years ago

You have mentioned the Ethernet port is not currently configured in LiteBSD for SDZL board.

Is it possible to configure without having to rebuild the kernel? If so is it just a matter of adding/changing SD card based config files, which files?

If you could point me in the right direction that would be great. Thanks.