Skip to content

Commit

Permalink
AT32UC3A: Implement initial BSP support for SimpleMachines' Mizar32-B (
Browse files Browse the repository at this point in the history
  • Loading branch information
ramangopalan authored Nov 16, 2023
1 parent 4ac9754 commit 0e82e13
Show file tree
Hide file tree
Showing 84 changed files with 9,193 additions and 4,075 deletions.
1,016 changes: 1,016 additions & 0 deletions bsp/avr32/at32uc3a0256/.config

Large diffs are not rendered by default.

136 changes: 136 additions & 0 deletions bsp/avr32/at32uc3a0256/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
mainmenu "RT-Thread Configuration"

config BSP_DIR
string
option env="BSP_ROOT"
default "."

config RTT_DIR
string
option env="RTT_ROOT"
default "../../.."

# you can change the RTT_ROOT default "../.." to your rtthread_root,
# example : default "F:/git_repositories/rt-thread"

config PKGS_DIR
string
option env="PKGS_ROOT"
default "packages"

config ENV_DIR
string
option env="ENV_ROOT"
default "/"

source "$RTT_DIR/Kconfig"
source "$PKGS_DIR/Kconfig"

menu "Hardware Drivers Config"

config SOC_AVR32
bool
default y

choice
prompt "Select BSP board"
default BSP_BOARD_MIZAR32B

config BSP_BOARD_MIZAR32B
bool "Mizar32-B"
endchoice

menu "On-chip Peripheral Drivers"

config BSP_USING_PIN
bool "Enable GPIO"
select RT_USING_PIN
default y

menuconfig BSP_USING_UART
bool "Enable UART"
select RT_USING_SERIAL
default y
if BSP_USING_UART
config BSP_USING_UART0
bool "Enable UART0"
default n
if BSP_USING_UART0
choice
prompt "uart0 tx pin number (GP)"
depends on BSP_USING_UART0
default BSP_UART0_TX_PIN_43
config BSP_UART0_TX_PIN_19
bool "19"
config BSP_UART0_TX_PIN_43
bool "43"
endchoice
config BSP_UART0_TX_PIN
int
default 19 if BSP_UART0_TX_PIN_19
default 43 if BSP_UART0_TX_PIN_43
config BSP_UART0_TX_PIN_FUNCTION
int
default 0 if BSP_UART0_TX_PIN_19
default 2 if BSP_UART0_TX_PIN_43
choice
prompt "uart0 rx pin number (GP)"
depends on BSP_USING_UART0
default BSP_UART0_RX_PIN_42
config BSP_UART0_RX_PIN_18
bool "18"
config BSP_UART0_RX_PIN_42
bool "42"
endchoice
config BSP_UART0_RX_PIN
int
default 18 if BSP_UART0_RX_PIN_18
default 42 if BSP_UART0_RX_PIN_42
config BSP_UART0_RX_PIN_FUNCTION
int
default 0 if BSP_UART0_RX_PIN_18
default 2 if BSP_UART0_RX_PIN_42
endif

config BSP_USING_UART1
bool "Enable UART1"
default y
if BSP_USING_UART1
choice
prompt "uart1 tx pin number (GP)"
depends on BSP_USING_UART1
default BSP_UART1_TX_PIN_6
config BSP_UART1_TX_PIN_6
bool "6"
config BSP_UART1_TX_PIN_95
bool "95"
endchoice
config BSP_UART1_TX_PIN
int
default 6 if BSP_UART1_TX_PIN_6
default 95 if BSP_UART1_TX_PIN_95
config BSP_UART1_TX_PIN_FUNCTION
int
default 0 if BSP_UART1_TX_PIN_6
default 1 if BSP_UART1_TX_PIN_95
choice
prompt "uart1 rx pin number (GP)"
depends on BSP_USING_UART1
default BSP_UART1_RX_PIN_5
config BSP_UART1_RX_PIN_5
bool "5"
config BSP_UART1_RX_PIN_96
bool "96"
endchoice
config BSP_UART1_RX_PIN
int
default 5 if BSP_UART1_RX_PIN_5
default 96 if BSP_UART1_RX_PIN_96
config BSP_UART1_RX_PIN_FUNCTION
int
default 0 if BSP_UART1_RX_PIN_5
default 1 if BSP_UART1_RX_PIN_96
endif
endif
endmenu
endmenu
171 changes: 171 additions & 0 deletions bsp/avr32/at32uc3a0256/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
# SimpleMachines' Mizar32 Development Board

## Introduction

The Mizar32 is a 32-bit computer based on the AVR32 processor. It is
clocked at 66MHz and has 32MB of main memory. It supports mass storage
on SD card, a USB connector, an on-board LED, two buttons, a JTAG port
and six bus connectors.

![board-snap](figures/board-snap.png)

The bus connectors let you add other stackable hardware modules such
as serial ports, ethernet, a 16x2 character LCD display and a
VGA/keyboard/mouse/audio board based on the 8-core Parallax Propeller
processor.

The Mizar32 is designed by SimpleMachines, Italy.

This board support package aims at adding RT-Thread support for the
following Mizar32 development boards.

| Model | Flash | SRAM | SDRAM |
| --------- | ----- | ---- | ---- |
| Mizar32-A | 512KB | 64KB | 32MB |
| Mizar32-B | 256KB | 64KB | 32MB |
| Mizar32-C | 128KB | 64KB | 32MB |

## Specification

- Main processor: AVR32 UC3A0 @ 66 MHz
- Internal fast SRAM: 32KB or 64KB with single-cycle access time
- On-board SDRAM: 32MB with 2-cycle access time
- Internal Flash memory: 128/256/512KB with single-cycle access time
- External Flash memory: up to 4GB on micro SD card.
- Internal operating Voltage: 3.3V with 5V input tolerant I/O
- Digital I/O Pins: 66
- Timer/Counter: 3 channel, 16-bit.
- Analog-to-Digital input pins: 8 with 10-bit resolution measuring 0-3.3v at up to 384,000 samples per second
- Stereo audio bitstream Digital-to-Analog Converter with 16 bit resolution at up to 48kHz
- Pulse Width Modulation channels (PWM): 7
- Universal Sync/Async RX/TX (USART): 2
- Serial Periperal Interface (SPI): 2
- Two-Wire Interface (TWI): 1, I2C-compatible at up to 400kbit/s
- Universal Serial Bus (USB): 1 OTG host with dedicated cable.
- Debug Port: JTAG connector
- Ethernet MAC 10/100: 1 (requires add-on hardware module)
- Oscillators: 2 (12MHz and 32768Hz)
- Buttons: Reset button, user button
- LEDs: Power LED, User LED
- Power supply: 5V USB or 7.5V-35V DC, 80mA (base board) to 222mA (with all add-on modules)
- Dimensions: 96,5mm x 63,5mm
- Weight: 42.5 grams
- Temperature range: -45 to +85°C

## Embedded Hardware Interfaces

- MicroSD
- USB
- JTAG
- Add-on bus connectors 1-6 interfaces on the Add-on Bus
- 12 General Purpose I/O pins
- 2 UARTs: one basic, one with modem control signals
- 2 SPI
- I2C interface with 2-way splitter
- 8 ADC inputs
- 3 high-resolution timers
- Ethernet

## Optional Stacked Modules

![Ethernet and Real Time Clock](figures/Mizar32_Ethernet_RTC_Module.jpg)

![16x2 I2C LCD Module](figures/Mizar32_I2C_LCD_Module.jpg)

![RS-232/RS-485 Module](figures/Mizar32_RS_232_485_Module.jpg)

![VGA Output, PS/2 Input, Audio Output](figures/Mizar32_VGA_Propeller_Module.jpg)

![PHT Prototype Board](figures/Mizar32_Protoboard_PHT.jpg)

![SMD Prototype Board](figures/Mizar32_Protoboard_SMD.jpg)

This README is essentially a work-in-progress. I will try to further
and documentation as and when I further the device driver base for the
Mizar32 target.

If you feel like reaching out to me for questions pertaining to the
target development board, you can write to me: ramangopalan AT gmail
dot com.

## Supported compiler

This BSP is built with the AVR32 GCC that comes with the Microchip
Studio. I am using the Microchip Studio version 7.0.2594. Make sure
that avr32-gcc.exe is visible on your command line. Add the binary
directory to you PATH.

![env-windows-avr32-gcc](figures/env-windows-avr32-gcc.png)

I use Git Bash (Windows) for compiling the RT-Thread system. Once you
set your path correctly, invoke Git Bash to query avr32-gcc.exe's
version. The output should look similar to this:

```bash
$ avr32-gcc.exe --version
avr32-gcc.exe (AVR_32_bit_GNU_Toolchain_3.4.2_435) 4.4.7
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
```

If you see this, you're all set to compile RT-Thread for Mizar32.

## Program firmware

### Step 1: download the RT-Thread codebase and navigate to bsp/avr32uc3a0.

```bash
$ cd bsp/avr32uc3a0/
```

### Step 2: build

```bash
scons -c
scons
```

### Step 3: flash

If everything went well, scons should have generated an elf file:
rtthread-uc3a0256.elf. Let us program the file. The program 'atprogram'
comes with Microchip Studio. I didn't have to do much here. Just make sure
`atprogram.exe' is in your PATH.

```bash
atprogram -t atmelice -i jtag -d at32uc3a0256 program -f rtthread-uc3a0256.elf
```

Note that you should already see the on-board LED (PB29) blink if your
programming was successful. I use the Atmel ICE programmer. To access
msh with the default menuconfig's configuration, you'll need the VGA
shield. Connect the target board to a 12 VDC wall adapter. Also
connect the shield to a VGA monitor and a PS/2 keyboard.

## Running Result

The output information on serial port for `ps' the command should look like this:

```bash
0x000003c0 tidle0 31 ready 0x00000054 0x00000100 67% 0x00000009 OK
0x00001650 tshell 20 running 0x000000b4 0x00001000 13% 0x0000000a OK
0x00001350 led1 5 suspend 0x0000007c 0x00000400 12% 0x00000005 EINTRPT
```

Here is a picture of the RT-Thread session on the VGA monitor:

![RT-Thread VGA Session on Mizar32](figures/mizar32-vga-out.jpg)

## Peripheral Support

| Drive | Support | Remark |
| ----- | ------- | ------- |
| UART | Support | UART0/1 |
| GPIO | Support | - |
| I2C | - | - |
| RTC | - | - |
| SPI | - | - |
| TIMER | - | - |
| WDT | - | - |

11 changes: 11 additions & 0 deletions bsp/avr32/at32uc3a0256/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import rtconfig
Import('RTT_ROOT')
from building import *

src_bsp = ['application.c', 'startup.c', 'board.c']

src = File(src_bsp)
CPPPATH = [RTT_ROOT + '/bsp/avr32']
group = DefineGroup('Startup', src, depend = [''], CPPPATH = CPPPATH)

Return('group')
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import rtconfig
if os.getenv('RTT_ROOT'):
RTT_ROOT = os.getenv('RTT_ROOT')
else:
RTT_ROOT = os.path.normpath(os.getcwd() + '/../..')
RTT_ROOT = os.path.normpath(os.getcwd() + '/../../..')

sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
from building import *
Expand All @@ -27,7 +27,10 @@ Export('rtconfig')
objs = PrepareBuilding(env, RTT_ROOT)

# AVR32 software framework building script
objs = objs + SConscript(RTT_ROOT + '/bsp/avr32uc3b0/SOFTWARE_FRAMEWORK/SConscript', variant_dir='bsp/SOFTWARE_FRAMEWORK', duplicate=0)
objs = objs + SConscript(RTT_ROOT + '/bsp/avr32/software_framework/SConscript', variant_dir='build/software_framework', duplicate=0)

# Driver abstractions
objs = objs + SConscript(RTT_ROOT + '/bsp/avr32/drivers/SConscript', variant_dir='build/drivers/', duplicate=0)

# make a building
DoBuilding(TARGET, objs)
47 changes: 47 additions & 0 deletions bsp/avr32/at32uc3a0256/application.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2006-2023, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2010-03-30 Kyle First version
* 2023-10-25 Raman Gopalan AT32UC3A: Access GPIO using RT's pin abstractions
*/

#include <rtthread.h>
#include <rtdevice.h>
#include "compiler.h"
#include "gpio.h"

/* Mizar32's built-in LED */
#define USER_LED_1 AVR32_PIN_PB29

char thread_led1_stack[1024];
struct rt_thread thread_led1;
static void rt_thread_entry_led1(void* parameter)
{
rt_pin_mode(USER_LED_1, PIN_MODE_OUTPUT);
while (1)
{
rt_pin_write(USER_LED_1, 1);
rt_thread_delay(RT_TICK_PER_SECOND / 2); /* sleep 0.5 second and switch to other thread */

rt_pin_write(USER_LED_1, 0);
rt_thread_delay(RT_TICK_PER_SECOND / 2);
}
}

int rt_application_init()
{
/* create led1 thread */
rt_thread_init(&thread_led1,
"led1",
rt_thread_entry_led1,
RT_NULL,
&thread_led1_stack[0],
sizeof(thread_led1_stack), 5, 5);
rt_thread_startup(&thread_led1);

return 0;
}
Loading

0 comments on commit 0e82e13

Please sign in to comment.