1
0
Fork 0
forked from nuttx/nuttx-update

boards/same70-qmtech: add support of SAME70 QMTECH board

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
This commit is contained in:
Petro Karashchenko 2021-11-27 16:03:13 +02:00 committed by Xiang Xiao
parent 31809724e1
commit 4b2b7d1d91
43 changed files with 5958 additions and 0 deletions

View file

@ -2079,6 +2079,8 @@ Below is a guide to the available README files in the NuttX source tree:
| | | `- metro-m4/
| | | `- README.txt
| | |- samv7/
| | | |- same70-qmtech/
| | | | `- README.txt
| | | |- same70-xplained/
| | | | `- README.txt
| | | `- samv71-xult/

View file

@ -1646,6 +1646,15 @@ config ARCH_BOARD_SAM4S_XPLAINED_PRO
---help---
The port of NuttX to the Atmel SAM4S-Xplained Pro development board.
config ARCH_BOARD_SAME70_QMTECH
bool "Atmel SAME70 evaluation board from QMTECH"
depends on ARCH_CHIP_SAME70N19
select ARCH_HAVE_LEDS
select ARCH_HAVE_BUTTONS
select ARCH_HAVE_IRQBUTTONS
---help---
The port of NuttX to the Atmel SAME70 evaluation board from QMTECH.
config ARCH_BOARD_SAME70_XPLAINED
bool "Atmel SAME70 Xplained evaluation board"
depends on ARCH_CHIP_SAME70Q21
@ -2493,6 +2502,7 @@ config ARCH_BOARD
default "sam4l-xplained" if ARCH_BOARD_SAM4L_XPLAINED
default "sam4s-xplained" if ARCH_BOARD_SAM4S_XPLAINED
default "sam4s-xplained-pro" if ARCH_BOARD_SAM4S_XPLAINED_PRO
default "same70-qmtech" if ARCH_BOARD_SAME70_QMTECH
default "same70-xplained" if ARCH_BOARD_SAME70_XPLAINED
default "samv71-xult" if ARCH_BOARD_SAMV71_XULT
default "shenzhou" if ARCH_BOARD_SHENZHOU
@ -2851,6 +2861,9 @@ endif
if ARCH_BOARD_METRO_M4
source "boards/arm/samd5e5/metro-m4/Kconfig"
endif
if ARCH_BOARD_SAME70_QMTECH
source "boards/arm/samv7/same70-qmtech/Kconfig"
endif
if ARCH_BOARD_SAME70_XPLAINED
source "boards/arm/samv7/same70-xplained/Kconfig"
endif

View file

@ -716,6 +716,9 @@ boards/arm/sam34/sam4s-xplained
boards/arm/sam34/sam4s-xplained-pro
The port of NuttX to the Atmel SAM4S-Xplained Pro development board.
boards/arm/samv7/same70-qmtech
The port of NuttX to the Atmel SAME70 evaluation board from QMTECH.
boards/arm/samv7/same70-xplained
The port of NuttX to the Atmel SAME70 Xplained evaluation board.

View file

@ -0,0 +1,98 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
if ARCH_BOARD_SAME70_QMTECH
config SAME70QMTECH_HSMCI0_AUTOMOUNT
bool "HSMCI0 automounter"
default n
depends on FS_AUTOMOUNTER && SAMV7_HSMCI0
if SAME70QMTECH_HSMCI0_AUTOMOUNT
config SAME70QMTECH_HSMCI0_AUTOMOUNT_FSTYPE
string "HSMCI0 file system type"
default "vfat"
config SAME70QMTECH_HSMCI0_AUTOMOUNT_BLKDEV
string "HSMCI0 block device"
default "/dev/mmcsd0"
config SAME70QMTECH_HSMCI0_AUTOMOUNT_MOUNTPOINT
string "HSMCI0 mount point"
default "/mnt/sdcard0"
config SAME70QMTECH_HSMCI0_AUTOMOUNT_DDELAY
int "HSMCI0 debounce delay (milliseconds)"
default 1000
config SAME70QMTECH_HSMCI0_AUTOMOUNT_UDELAY
int "HSMCI0 unmount retry delay (milliseconds)"
default 2000
endif # SAME70QMTECH_HSMCI0_AUTOMOUNT
config SAME70QMTECH_PROGMEM_OTA_PARTITION
bool
default n
select MTD
select MTD_BYTE_WRITE
select MTD_PARTITION
select MTD_PROGMEM
select MTD_PROGMEM_ERASESTATE
menuconfig SAME70QMTECH_FORMAT_MCUBOOT
bool "MCUboot-bootable format"
default n
select SAME70QMTECH_PROGMEM_OTA_PARTITION
---help---
The MCUboot support of loading the firmware images.
if SAME70QMTECH_FORMAT_MCUBOOT
config SAME70QMTECH_MCUBOOT_BOOTLOADER
bool "MCUboot bootloader application"
default n
---help---
This switch between linker scripts to allow an application be
built to another entry point address.
comment "MCUboot Application Image OTA Update support"
config SAME70QMTECH_OTA_PRIMARY_SLOT_OFFSET
hex "MCUboot application image primary slot offset"
default "0x20000"
config SAME70QMTECH_OTA_PRIMARY_SLOT_DEVPATH
string "Application image primary slot device path"
default "/dev/ota0"
config SAME70QMTECH_OTA_SECONDARY_SLOT_OFFSET
hex "MCUboot application image secondary slot offset"
default "0x48000"
config SAME70QMTECH_OTA_SECONDARY_SLOT_DEVPATH
string "Application image secondary slot device path"
default "/dev/ota1"
config SAME70QMTECH_OTA_SLOT_SIZE
hex "MCUboot application image slot size (in bytes)"
default "0x28000"
config SAME70QMTECH_OTA_SCRATCH_OFFSET
hex "MCUboot scratch partition offset"
default "0x70000"
config SAME70QMTECH_OTA_SCRATCH_DEVPATH
string "Scratch partition device path"
default "/dev/otascratch"
config SAME70QMTECH_OTA_SCRATCH_SIZE
hex "MCUboot scratch partition size (in bytes)"
default "0x10000"
endif # SAME70QMTECH_FORMAT_MCUBOOT
endif # ARCH_BOARD_SAME70_QMTECH

View file

@ -0,0 +1,819 @@
README
======
This README file discusses the port of NuttX to the Atmel SAM E70 board from
QMTECH. This board features the ATSAME70N19 Cortex-M7 microcontroller.
Contents
========
- Status/Open Issues
- Serial Console
- SD card
- Automounter
- LEDs and Buttons
- Program FLASH Access
- SPI Slave
- Tickless OS
- Debugging
- Using OpenOCD and GDB to flash via the EDBG chip
- Configurations
Status/Open Issues
==================
2015-11-30: The basic NSH configuration is function with serial console
via the EDBG VCOM and LED and buttons support. SD card slot also appear
to be fully functional.
See also boards/arm/samv7/samv70-xplained/README.txt
Serial Console
==============
The SAME70-QMTECH has no on-board RS-232 drivers so it will be necessary to
use either the VCOM or an external RS-232 driver. Here are some options.
- Arduino Serial Shield: One option is to use an Arduino-compatible
serial shield. This will use the RXD and TXD signals available at pins
0 an 1, respectively, of the Arduino "Digital Low" connector. On the
SAME70-QMTECH board, this corresponds to UART3:
------ ------ ------- ------- --------
Pin on SAME70 Arduino Arduino SAME70
J503 PIO Name Pin Function
------ ------ ------- ------- --------
1 PD28 D0/RX0 0 URXD3
2 PD30 D1/TX0 1 UTXD3
------ ------ ------- ------- --------
In this configuration, an external RS232 driver can also be used
instead of the shield. Simply connext as follows:
--------- -----------
Arduino RS-232
Pin Label Connection
--------- -----------
D0 (RXD) RX
D1 (TXD) TX
GND GND
5VO Vcc
--------- -----------
SD Card
=======
Card Slot
---------
The SAM E70 QMTECH has one standard SD card connector that is connected to
the High Speed Multimedia Card Interface (HSMCI) of the SAM
E70. SD card connector:
------ ----------------- ---------------------
SAME70 SAME70 Shared functionality
Pin Function
------ ----------------- ---------------------
PA30 MCDA0 (DAT0)
PA31 MCDA1 (DAT1)
PA26 MCDA2 (DAT2)
PA27 MCDA3 (DAT3)
PA25 MCCK (CLK) Shield
PA28 MCCDA (CMD)
PD17 Card Detect (C/D) Shield
------ ----------------- ---------------------
Configuration Settings
----------------------
Enabling HSMCI support. The SAME70-QMTECH provides a one, full-size SD memory
card slots. The full size SD card slot connects via HSMCI0. Support for
the SD slots can be enabled with the following settings:
System Type->SAMV7 Peripheral Selection
CONFIG_SAMV7_HSMCI0=y : To enable HSMCI0 support
CONFIG_SAMV7_XDMAC=y : XDMAC is needed by HSMCI0/1
System Type
CONFIG_SAMV7_GPIO_IRQ=y : PIO interrupts needed
CONFIG_SAMV7_GPIOD_IRQ=y : Card detect pin is on PD18
Device Drivers -> MMC/SD Driver Support
CONFIG_MMCSD=y : Enable MMC/SD support
CONFIG_MMSCD_NSLOTS=1 : One slot per driver instance
CONFIG_MMCSD_MULTIBLOCK_DISABLE=y : (REVISIT)
CONFIG_MMCSD_HAVE_CARDDETECT=y : Supports card-detect PIOs
CONFIG_MMCSD_MMCSUPPORT=n : Interferes with some SD cards
CONFIG_MMCSD_SPI=n : No SPI-based MMC/SD support
CONFIG_MMCSD_SDIO=y : SDIO-based MMC/SD support
CONFIG_SDIO_DMA=y : Use SDIO DMA
CONFIG_SDIO_BLOCKSETUP=y : Needs to know block sizes
RTOS Features -> Work Queue Support
CONFIG_SCHED_WORKQUEUE=y : Driver needs work queue support
Application Configuration -> NSH Library
CONFIG_NSH_ARCHINIT=y : NSH board-initialization, OR
CONFIG_BOARD_LATE_INITIALIZE=y
Using the SD card
-----------------
1) After booting, the HSCMI device will appear as /dev/mmcsd0.
2) If you try mounting an SD card with nothing in the slot, the mount will
fail:
nsh> mount -t vfat /dev/mmcsd0 /mnt/sd0
nsh: mount: mount failed: 19
NSH can be configured to provide errors as strings instead of
numbers. But in this case, only the error number is reported. The
error numbers can be found in nuttx/include/errno.h:
#define ENODEV 19
#define ENODEV_STR "No such device"
So the mount command is saying that there is no device or, more
correctly, that there is no card in the SD card slot.
3) Inserted the SD card. Then the mount should succeed.
nsh> mount -t vfat /dev/mmcsd0 /mnt/sd0
nsh> ls /mnt/sd1
/mnt/sd1:
atest.txt
nsh> cat /mnt/sd1/atest.txt
This is a test
NOTE: See the next section entitled "Auto-Mounter" for another way
to mount your SD card.
4) Before removing the card, you must umount the file system. This is
equivalent to "ejecting" or "safely removing" the card on Windows: It
flushes any cached data to an SD card and makes the SD card unavailable
to the applications.
nsh> umount -t /mnt/sd0
It is now safe to remove the card. NuttX provides into callbacks
that can be used by an application to automatically unmount the
volume when it is removed. But those callbacks are not used in
these configurations.
Auto-Mounter
============
NuttX implements an auto-mounter than can make working with SD cards
easier. With the auto-mounter, the file system will be automatically
mounted when the SD card is inserted into the HSMCI slot and automatically
unmounted when the SD card is removed.
Here is a sample configuration for the auto-mounter:
File System Configuration
CONFIG_FS_AUTOMOUNTER=y
Board-Specific Options
CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT=y
CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_FSTYPE="vfat"
CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_BLKDEV="/dev/mmcsd0"
CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_MOUNTPOINT="/mnt/sdcard"
CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_DDELAY=1000
CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_UDELAY=2000
WARNING: SD cards should never be removed without first unmounting
them. This is to avoid data and possible corruption of the file
system. Certainly this is the case if you are writing to the SD card
at the time of the removal. If you use the SD card for read-only access,
however, then I cannot think of any reason why removing the card without
mounting would be harmful.
LEDs and Buttons
================
LEDs
----
A single LED is available driven by PA14.
This LED is not used by the board port unless CONFIG_ARCH_LEDS is
defined. In that case, the usage by the board port is defined in
include/board.h and src/sam_autoleds.c. The LED is used to encode
OS-related events as follows:
------------------- ----------------------- ------
SYMBOL Meaning LED
------------------- ----------------------- ------
LED_STARTED NuttX has been started OFF
LED_HEAPALLOCATE Heap has been allocated OFF
LED_IRQSENABLED Interrupts enabled OFF
LED_STACKCREATED Idle stack created ON
LED_INIRQ In an interrupt N/C
LED_SIGNAL In a signal handler N/C
LED_ASSERTION An assertion failed N/C
LED_PANIC The system has crashed FLASH
Thus if the LED is statically on, NuttX has successfully booted and is,
apparently, running normally. If the LED is flashing at approximately
2Hz, then a fatal error has been detected and the system has halted.
Buttons
-------
SAM E70 QMTECH contains two mechanical buttons. One button is the RESET
button connected to the SAM E70 reset line and the other, PA21, is a generic
user configurable button. When a button is pressed it will drive the I/O
line to GND.
NOTE: There are no pull-up resistors connected to the generic user buttons
so it is necessary to enable the internal pull-up in the SAM E70 to use the
button.
SPI Slave
=========
An interrutp driven SPI slave driver as added on 2015-08-09 but has not
been verified as of this writing. See discussion in include/nuttx/spi/slave.h
and below.
I do not yet have a design that supports SPI slave DMA. And, under
certain, very limited conditions, I think it can be done. Those
certain conditions are:
a) The master does not tie the chip select to ground. The master must
raise chip select at the end of the transfer. Then I do not need to
know the length of the transfer; I can cancel the DMA when the chip
is de-selected.
b) The protocol includes a dummy read after sending the command. This
is very common in SPI device and should not be an issue if it is
specified. This dummy read time provides time to set up the DMA.
So the protocol would be:
i) Master drops the chip select.
ii) Master sends the command which will indicate whether the master
is reading, writing, or exchanging data. The master discards
the garbage return value.
iii) Slave is interrupted when the command word is received. The
SPI device then decodes the command word and setups up the
subsequent DMA.
iv) Master sends a dummy word and discards the return value.
During the bit times to shift the dummy word, the slave has time
to set up the DMA.
v) Master then reads or writes (or exchanges) the data If the DMA
is in place, the transfer should continue normally.
vi) At the end of the data transfer the master raises the chip
select.
c) There are limitations in the word time, i.e., the time between the
interrupt for each word shifted in from the master.
The controller driver will get events after the receipt of each word in
ii), iv), and v). The time between each word will be:
word-time = nbits * bit time + inter-word-gap
So for an 8 bit interface at 20MHz, the words will be received from the
master a 8 * 50nsec = 400 nsec + inter-word-gap. That is the time
during which the dummy word would be shifted and during which we
receive the interrupt for the command word, interpret the command word,
and to set up the DMA for the remaining word transfer. I don't think
that is possible, at least not at 20 MHz.
That is far too fast even for the interrupt driven solution that I have
in place now. It could not work at 20MHz. If we suppose that interrupt
processing is around 1 usec, then an 8 bit interface could not have bit
times more than 125 nsec or 8 KHz. Interrupt handling should be faster
than 1 usec, but not a lot faster. I have not benchmarked it. NuttX
also supports special, zero latency interrupts that could bring the
interrupt time down even more.
Note that we would also have a little more processing time if you used
16-bit SPI word size.
Note also that the interrupt driven approach would have this same basic
performance limitation with the additional disadvantage that:
a) The driver will receive two interrupts per word exchanged:
i) One interrupt will be received when the word is shifted in from
the master (at the end of 8-bit times). This is a data received
interrupt.
ii) And another interrupt when the next words moved to the shift-out
register, freeing up the transmit holding register. This is the
data sent interrupt.
The ii) event should be very soon after the i) event.
Without DMA, the only way to reduce the interrupt rate would be to add
interrupt-level polling to detect the when transmit holding register
is available. That is not really a good idea.
b) It will hog all of the CPU for the duration of the transfer).
Tickless OS
===========
Background
----------
By default, a NuttX configuration uses a periodic timer interrupt that
drives all system timing. The timer is provided by architecture-specific
code that calls into NuttX at a rate controlled by CONFIG_USEC_PER_TICK.
The default value of CONFIG_USEC_PER_TICK is 10000 microseconds which
corresponds to a timer interrupt rate of 100 Hz.
An option is to configure NuttX to operation in a "tickless" mode. Some
limitations of default system timer are, in increasing order of
importance:
- Overhead: Although the CPU usage of the system timer interrupt at 100Hz
is really very low, it is still mostly wasted processing time. One most
timer interrupts, there is really nothing that needs be done other than
incrementing the counter.
- Resolution: Resolution of all system timing is also determined by
CONFIG_USEC_PER_TICK. So nothing that be time with resolution finer than
10 milliseconds be default. To increase this resolution,
CONFIG_USEC_PER_TICK an be reduced. However, then the system timer
interrupts use more of the CPU bandwidth processing useless interrupts.
- Power Usage: But the biggest issue is power usage. When the system is
IDLE, it enters a light, low-power mode (for ARMs, this mode is entered
with the wfi or wfe instructions for example). But each interrupt
awakens the system from this low power mode. Therefore, higher rates
of interrupts cause greater power consumption.
The so-called Tickless OS provides one solution to issue. The basic
concept here is that the periodic, timer interrupt is eliminated and
replaced with a one-shot, interval timer. It becomes event driven
instead of polled: The default system timer is a polled design. On
each interrupt, the NuttX logic checks if it needs to do anything
and, if so, it does it.
Using an interval timer, one can anticipate when the next interesting
OS event will occur, program the interval time and wait for it to fire.
When the interval time fires, then the scheduled activity is performed.
Configuration
-------------
The following configuration options will enable support for the Tickless
OS for the SAMV7 platforms using TC0 channels 0-3 (other timers or
timer channels could be used making the obvious substitutions):
RTOS Features -> Clocks and Timers
CONFIG_SCHED_TICKLESS=y : Configures the RTOS in tickless mode
CONFIG_SCHED_TICKLESS_ALARM=n : (option not implemented)
CONFIG_SCHED_TICKLESS_LIMIT_MAX_SLEEP=y
System Type -> SAMV7 Peripheral Support
CONFIG_SAMV7_TC0=y : Enable TC0 (TC channels 0-3
System Type -> Timer/counter Configuration
CONFIG_SAMV7_ONESHOT=y : Enables one-shot timer wrapper
CONFIG_SAMV7_FREERUN=y : Enabled free-running timer wrapper
CONFIG_SAMV7_TICKLESS_ONESHOT=0 : Selects TC0 channel 0 for the one-shot
CONFIG_SAMV7_TICKLESS_FREERUN=1 : Selects TC0 channel 1 for the free-
: running timer
The resolution of the clock is provided by the CONFIG_USEC_PER_TICK
setting in the configuration file.
NOTE: In most cases, the slow clock will be used as the timer/counter
input. The SAME70-Xplained board has pads for a 32.768KHz crystal,
however, the boad ships with that position unpopulated. So, be default
this will probably end up using the slow RC oscillator which will give
you very bad timing.
If you add a crystal to your board, you can select to use it with the
definition BOARD_HAVE_SLOWXTAL in the boards/arm/samv7/same70-qmtech/board.h
file.
The slow clock has a resolution of about 30.518 microseconds. Ideally,
the value of CONFIG_USEC_PER_TICK should be the exact clock resolution.
Otherwise there will be cumulative timing inaccuracies. But a choice
choice of:
CONFIG_USEC_PER_TICK=31
will have an error of 0.6% and will have inaccuracies that will
effect the time due to long term error build-up.
Using the slow clock input, the Tickless support is functional,
however, there are inaccuracies in delays. For example,
nsh> sleep 10
results in a delay of maybe 5.4 seconds. But the timing accuracy is
correct if all competing uses of the interval timer are disabled (mostly
from the high priority work queue). Therefore, I conclude that this
inaccuracy is due to the inaccuracies in the representation of the clock
rate. 30.518 usec cannot be represented accurately. Each timing
calculation results in a small error. When the interval timer is very
busy, long delays will be divided into many small pieces and each small
piece has a large error in the calculation. The cumulative error is the
cause of the problem.
Solution: The same70-qmtech/src/sam_boot.c file has additional logic
to enable the programmable clock PCK6 as a clock source for the
timer/counters if the Tickless mode is selected. The ideal frequency
would be:
frequency = 1,000,000 / CONFIG_USEC_PER_TICK
The main crystal is selected as the frequency source. The maximum
prescaler value is 256 so the minimum frequency is 46,875 Hz which
corresponds to a period of 21.3 microseconds. A value of
CONFIG_USEC_PER_TICK=20, or 50KHz, would give an exact solution with
a divider of 240.
SAME70 Timer Usage
------------------
This current implementation uses two timers: A one-shot timer to
provide the timed events and a free running timer to provide the current
time. Since timers are a limited resource, that could be an issue on
some systems.
We could do the job with a single timer if we were to keep the single
timer in a free-running at all times. The SAME70 timer/counters have
16-bit counters with the capability to generate a compare interrupt when
the timer matches a compare value but also to continue counting without
stopping (giving another, different interrupt when the timer rolls over
from 0xffff to zero). So we could potentially just set the compare at
the number of ticks you want PLUS the current value of timer. Then you
could have both with a single timer: An interval timer and a free-
running counter with the same timer! In this case, you would want to
to set CONFIG_SCHED_TICKLESS_ALARM in the NuttX configuration.
Patches are welcome!
Debugging
=========
EDBG
----
The on-board EDBG appears to work only with Atmel Studio. You can however,
simply connect a SAM-ICE or J-Link to the JTAG/SWD connector on the board
and that works great. The only tricky thing is getting the correct
orientation of the JTAG connection.
J-Link/JTAG
-----------
I have been using Atmel Studio to write code to flash then I use the Segger
J-Link GDB server to debug. I have been using the 'Device Programming' I
available under the Atmel Studio 'Tool' menu. I have to disconnect the
SAM-ICE while programming with the EDBG. I am sure that you could come up
with a GDB server-only solution if you wanted.
I run GDB like this from the directory containing the NuttX ELF file:
arm-none-eabi-gdb
(gdb) target remote localhost:2331
(gdb) mon reset
(gdb) file nuttx
(gdb) ... start debugging ...
OpenOCD/EDBG
------------
Current OpenOCD also works with SAME70-QMTECH via EDBG, but I have not
used OpenOCD with the board.
SAM-BA
------
SAM-BA is another option. With SAM-BA, you can load code into FLASH over
a serial port or USB connection by booting into the ROM bootloader.
CMSIS-DAP Programmer
--------------------
Another useful tool for CMSIS-DAP programmer (formerly Atmel EDBG
programmer) available at:
https://github.com/ataradov/edbg
This is a simple command line utility for programming ARM-based MCUs
(currently only Atmel) though CMSIS-DAP SWD interface. It works on Linux,
macOS and Windows. Very useful to around especially if you have the
following issue:
Booting to FLASH or the ROM Bootloader
--------------------------------------
If you use EDBG or JTAG to load code into FLASH, you may be puzzled why
the code does not run. It may be that you are booting into the ROM
bootloader instead of FLASH. That can be fixed by modifying the SAME70's
GPNVM bits.
If your SAME70 is booting in ROM by default, the GPNVM bits will probably
looking something like:
$ edbg.exe -F r,:, -t atmel_cm7
GPNVM Bits: 0x40
Where bit 1 = 0 boots into the ROM bootloader and bit 1 = 1 boots into
FLASH. You want:
$ edbg.exe -F r,:, -t atmel_cm7
GPNVM Bits: 0x42
If you are trying to use SAM-BA, you might have the opposity problem:
The board might be booting into FLASH when you need it to boot into the
ROM bootloader.
That GPNVM bit can be changed using CMSIS-DAP programmer, Atmel studio, or
using this OpenOCD setup:
atsamv gpnvm [('clr'|'set'|'show') bitnum]
Without arguments, shows all bits in the gpnvm register.
Otherwise, clears, sets, or shows one General Purpose Non-Volatile
Memory (gpnvm) bit.
Perhaps SAM-BA supports a way to do this as well???
Using OpenOCD and GDB to flash via the EDBG chip
================================================
Building OpenOCD under Cygwin:
Refer to boards/olimex-lpc1766stk/README.txt
Installing OpenOCD in Linux (but see note below):
sudo apt-get install openocd
NOTE: At the time of writing installing the above openocd package from
the distribution (Ubuntu 14.04) was not enough to get the latest openocd
version supporting the SAME70 Xplained.
The code was obtained from the OpenOCD git repository, available at
https://github.com/ntfreak/openocd.
git clone https://github.com/ntfreak/openocd.git
Then follow the directions of the "Building OpenOCD" section of their README,
but be sure to configure including the CMSIS-DAP interface:
./bootstrap
./configure --enable-cmsis-dap
make
sudo make install
If your configure step fails, you might be missing some dependencies, i.e.:
sudo apt-get install libhidapi-dev
Helper Scripts.
OpenOCD requires a configuration file. I keep the one I used last here:
boards/arm/samv7/same70-qmtech/tools/atmel_same70_qmtech.cfg
However, the "correct" configuration script to use with OpenOCD may
change as the features of OpenOCD evolve. So you should at least
compare that atmel_same70_qmtech.cfg file with configuration files in
/usr/share/openocd/scripts. As of this writing, the configuration
files of interest were:
/usr/share/openocd/scripts/interface/cmsis-dap.cfg
/usr/share/openocd/scripts/board/atmel_same70_qmtech.cfg
/usr/share/openocd/scripts/target/atsamv.cfg
There is also a script on the tools/ directory that I use to start
the OpenOCD daemon on my system called oocd.sh. That script will
probably require some modifications to work in another environment:
- Possibly the value of OPENOCD_PATH and TARGET_PATH
- It assumes that the correct script to use is the one at
boards/arm/samv7/same70-qmtech/tools/atmel_same70_qmtech.cfg
Starting OpenOCD
Then you should be able to start the OpenOCD daemon like:
boards/arm/samv7/same70-qmtech/tools/oocd.sh $PWD
Connecting GDB
Once the OpenOCD daemon has been started, you can connect to it via
GDB using the following GDB command:
arm-nuttx-elf-gdb
(gdb) target remote localhost:3333
NOTE: The name of your GDB program may differ. For example, with the
CodeSourcery toolchain, the ARM GDB would be called arm-none-eabi-gdb.
After starting GDB, you can load the NuttX ELF file:
(gdb) symbol-file nuttx
(gdb) monitor reset
(gdb) monitor halt
(gdb) load nuttx
NOTES:
1. Loading the symbol-file is only useful if you have built NuttX to
include debug symbols (by setting CONFIG_DEBUG_SYMBOLS=y in the
.config file).
2. The MCU must be halted prior to loading code using 'mon reset'
as described below.
OpenOCD will support several special 'monitor' commands. These
GDB commands will send comments to the OpenOCD monitor. Here
are a couple that you will need to use:
(gdb) monitor reset
(gdb) monitor halt
NOTES:
1. The MCU must be halted using 'mon halt' prior to loading code.
2. Reset will restart the processor after loading code.
3. The 'monitor' command can be abbreviated as just 'mon'.
Configurations
==============
Information Common to All Configurations
----------------------------------------
Each SAME70-QMTECH configuration is maintained in a sub-directory and
can be selected as follow:
tools/configure.sh same70-qmtech:<subdir>
Before building, make sure that the PATH environment variable include the
correct path to the directory than holds your toolchain binaries.
And then build NuttX by simply typing the following. At the conclusion of
the make, the nuttx binary will reside in an ELF file called, simply, nuttx.
make oldconfig
make
The <subdir> that is provided above as an argument to the tools/configure.sh
must be is one of the following.
NOTES:
1. These configurations use the mconf-based configuration tool. To
change any of these configurations using that tool, you should:
a. Build and install the kconfig-mconf tool. See nuttx/README.txt
see additional README.txt files in the NuttX tools repository.
b. Execute 'make menuconfig' in nuttx/ in order to start the
reconfiguration process.
2. Unless stated otherwise, all configurations generate console
output on USART1 (the EDBG VCOM)
NOTE: When USART1 is used, the pin PB4 is reconfigured. Normally, PB4
is TDI. When it is reconfigured for use with USART1, the capability to
debug is lost! If you plan to debug you should most certainly not use
USART1. UART3 might be a good option (the Arduino RXD/TXD):
-CONFIG_SAMV7_USART1=y
-CONFIG_USART1_SERIALDRIVER=y
-CONFIG_USART1_SERIAL_CONSOLE=y
-CONFIG_USART1_RXBUFSIZE=256
-CONFIG_USART1_TXBUFSIZE=256
-CONFIG_USART1_BAUD=115200
-CONFIG_USART1_BITS=8
-CONFIG_USART1_PARITY=0
-CONFIG_USART1_2STOP=0
+CONFIG_SAMV7_UART3=y
+CONFIG_UART3_SERIAL_CONSOLE=y
+CONFIG_UART3_RXBUFSIZE=256
+CONFIG_UART3_TXBUFSIZE=256
+CONFIG_UART3_BAUD=115200
+CONFIG_UART3_BITS=8
+CONFIG_UART3_PARITY=0
+CONFIG_UART3_2STOP=0
UART3 is not the default because (1) the placement of the RJ-45 connector
makes it difficult to install Arduino shield cards and (2) the Arduino
connectors are not populated on the board as it comes from the factory.
3. All of these configurations are set up to build under Windows using the
"GNU Tools for ARM Embedded Processors" that is maintained by ARM
(unless stated otherwise in the description of the configuration).
https://developer.arm.com/open-source/gnu-toolchain/gnu-rm
That toolchain selection can easily be reconfigured using
'make menuconfig'. Here are the relevant current settings:
Build Setup:
CONFIG_HOST_WINDOWS=y : Window environment
CONFIG_WINDOWS_CYGWIN=y : Cywin under Windows
System Type -> Toolchain:
CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU ARM EABI toolchain
NOTE: As of this writing, there are issues with using this tool at
the -Os level of optimization. This has not been proven to be a
compiler issue (as least not one that might not be fixed with a
well placed volatile qualifier). However, in any event, it is
recommend that you use not more that -O2 optimization.
Configuration sub-directories
-----------------------------
adc
This is a basic nsh configuration (se below) with added example for
ADC (AFEC) driver. Data can be read through channel AFE0_AD0 by
running application "adc" in NuttShell.
The ADC is triggered by Timer/counter at 1 kHz frequency and uses
DMA to transfer samples. Number of transfered samples can be set
by configuring CONFIG_SAMV7_AFEC_DMASAMPLES.
nsh:
Configures the NuttShell (nsh) located at examples/nsh. There are two
very similar NSH configurations:
- nsh. This configuration is focused on low level, command-line
driver testing. It has no network.
- netnsh. This configuration is focused on network testing and
has only limited command support.
NOTES:
1. The serial console is configured by default for use with the EDBG VCOM
(USART1). You will need to reconfigure if you will to use a different
U[S]ART. See "Information Common to All Configurations" above.
2. Default stack sizes are large and should really be tuned to reduce
the RAM footprint:
CONFIG_ARCH_INTERRUPTSTACK=2048
CONFIG_IDLETHREAD_STACKSIZE=1024
CONFIG_USERMAIN_STACKSIZE=2048
CONFIG_PTHREAD_STACK_DEFAULT=2048
... and others ...
3. NSH built-in applications are supported.
Binary Formats:
CONFIG_BUILTIN=y : Enable support for built-in programs
Application Configuration:
CONFIG_NSH_BUILTIN_APPS=y : Enable starting apps from NSH command line
4. Support for HSMCI is built-in by default. The SAME70-QMTECH provides
one full-size SD memory card slot. Refer to the section entitled
"SD card" for configuration-related information.
See "Open Issues" above for issues related to HSMCI.
The auto-mounter is not enabled. See the section above entitled
"Auto-Mounter".
5. Performance-related Configuration settings:
CONFIG_ARMV7M_ICACHE=y : Instruction cache is enabled
CONFIG_ARMV7M_DCACHE=y : Data cache is enabled
CONFIG_ARMV7M_DCACHE_WRITETHROUGH=n : Write back mode
CONFIG_ARCH_FPU=y : H/W floating point support is enabled
CONFIG_ARCH_DPFPU=y : 64-bit H/W floating point support is enabled
# CONFIG_ARMV7M_ITCM is not set : Support not yet in place
# CONFIG_ARMV7M_DTCM is not set : Support not yet in place
Stack sizes are also large to simplify the bring-up and should be
tuned for better memory usages.
STATUS:
2015-03-28: HSMCI TX DMA is disabled. There are some issues with the TX
DMA that need to be corrected.
mcuboot-loader:
This configuration exercises the port of MCUboot loader to NuttX.
In this configuration both primary, secondary and scratch partitions are
mapped into the internal flash.
Relevant configuration settings:
CONFIG_BOARD_LATE_INITIALIZE=y
CONFIG_BOOT_MCUBOOT=y
CONFIG_MCUBOOT_BOOTLOADER=y
CONFIG_MCUBOOT_ENABLE_LOGGING=y
CONFIG_SAME70QMTECH_FORMAT_MCUBOOT=y
CONFIG_SAME70QMTECH_MCUBOOT_BOOTLOADER=y
CONFIG_USER_ENTRYPOINT="mcuboot_loader_main"
mcuboot-confirm:
This configuration exercises the MCUboot compatible application slot
confirm example.
Generate signed binaries for MCUboot compatible application:
./apps/boot/mcuboot/mcuboot/scripts/imgtool.py sign \
--key apps/boot/mcuboot/mcuboot/root-rsa-2048.pem --align 8 \
--version 1.0.0 --header-size 0x200 --pad-header --slot-size 0xe0000 \
nuttx/nuttx.bin signed_app_1_0_0.bin
Relevant configuration settings:
CONFIG_BOARD_LATE_INITIALIZE=y
CONFIG_BOOT_MCUBOOT=y
CONFIG_MCUBOOT_SLOT_CONFIRM_EXAMPLE=y
CONFIG_SAME70QMTECH_FORMAT_MCUBOOT=y
CONFIG_USER_ENTRYPOINT="mcuboot_confirm_main"

View file

@ -0,0 +1,64 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_MMCSD_MMCSUPPORT is not set
# CONFIG_SAMV7_UART0 is not set
# CONFIG_SAMV7_UART2 is not set
# CONFIG_SAMV7_UART4 is not set
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="same70-qmtech"
CONFIG_ARCH_BOARD_SAME70_QMTECH=y
CONFIG_ARCH_CHIP="samv7"
CONFIG_ARCH_CHIP_SAME70=y
CONFIG_ARCH_CHIP_SAME70N19=y
CONFIG_ARCH_CHIP_SAME70N=y
CONFIG_ARCH_CHIP_SAMV7=y
CONFIG_ARCH_INTERRUPTSTACK=2048
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARMV7M_DCACHE=y
CONFIG_ARMV7M_ICACHE=y
CONFIG_ARMV7M_LAZYFPU=y
CONFIG_BOARD_LATE_INITIALIZE=y
CONFIG_BOARD_LOOPSPERMSEC=51262
CONFIG_BOOT_MCUBOOT=y
CONFIG_BUILTIN=y
CONFIG_FAT_LCNAMES=y
CONFIG_FAT_LFN=y
CONFIG_FS_FAT=y
CONFIG_FS_PROCFS=y
CONFIG_MCUBOOT_SLOT_CONFIRM_EXAMPLE=y
CONFIG_MMCSD_MULTIBLOCK_DISABLE=y
CONFIG_MMCSD_SDIO=y
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_LINELEN=64
CONFIG_NSH_READLINE=y
CONFIG_PREALLOC_TIMERS=4
CONFIG_RAM_SIZE=262144
CONFIG_RAM_START=0x20400000
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_SAME70QMTECH_FORMAT_MCUBOOT=y
CONFIG_SAMV7_GPIOA_IRQ=y
CONFIG_SAMV7_GPIOD_IRQ=y
CONFIG_SAMV7_GPIO_IRQ=y
CONFIG_SAMV7_HSMCI0=y
CONFIG_SAMV7_PROGMEM=y
CONFIG_SAMV7_USART1=y
CONFIG_SAMV7_XDMAC=y
CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_WAITPID=y
CONFIG_SDCLONE_DISABLE=y
CONFIG_SDIO_BLOCKSETUP=y
CONFIG_START_DAY=24
CONFIG_START_MONTH=11
CONFIG_START_YEAR=2021
CONFIG_SYSTEM_NSH=y
CONFIG_SYSTEM_RAMTEST=y
CONFIG_USART1_SERIAL_CONSOLE=y
CONFIG_USER_ENTRYPOINT="mcuboot_confirm_main"

View file

@ -0,0 +1,85 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_MMCSD_MMCSUPPORT is not set
# CONFIG_MMCSD_SPI is not set
# CONFIG_SAMV7_UART0 is not set
# CONFIG_SAMV7_UART2 is not set
# CONFIG_SAMV7_UART4 is not set
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD_CUSTOM=y
CONFIG_ARCH_BOARD_CUSTOM_DIR="../autococo2-board"
CONFIG_ARCH_BOARD_CUSTOM_DIR_RELPATH=y
CONFIG_ARCH_BOARD_CUSTOM_NAME="ARCH_BOARD_AUTOCOCO2_BOARD"
CONFIG_ARCH_CHIP="samv7"
CONFIG_ARCH_CHIP_SAME70=y
CONFIG_ARCH_CHIP_SAME70Q21=y
CONFIG_ARCH_CHIP_SAME70Q=y
CONFIG_ARCH_CHIP_SAMV7=y
CONFIG_ARCH_INTERRUPTSTACK=2048
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARMV7M_DCACHE=y
CONFIG_ARMV7M_ICACHE=y
CONFIG_ARMV7M_LAZYFPU=y
CONFIG_AT24XX_ADDR=0x57
CONFIG_AT24XX_EXTENDED=y
CONFIG_AT24XX_EXTSIZE=160
CONFIG_AT24XX_SIZE=2
CONFIG_BOARD_LATE_INITIALIZE=y
CONFIG_BOARD_LOOPSPERMSEC=51262
CONFIG_BOOT_MCUBOOT=y
CONFIG_BUILTIN=y
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_FAT_LCNAMES=y
CONFIG_FAT_LFN=y
CONFIG_FS_FAT=y
CONFIG_FS_PROCFS=y
CONFIG_I2CTOOL_MAXBUS=0
CONFIG_INTELHEX_BINARY=y
CONFIG_MCUBOOT_SLOT_CONFIRM_EXAMPLE=y
CONFIG_MCUBOOT_VERSION="1a9c6d8495e4dbe7d02edf14bb8a9fa1d4e955c0"
CONFIG_MMCSD_MULTIBLOCK_DISABLE=y
CONFIG_MMCSD_SDIO=y
CONFIG_MTD=y
CONFIG_MTD_AT24XX=y
CONFIG_MTD_AT25=y
CONFIG_MTD_BYTE_WRITE=y
CONFIG_MTD_CONFIG=y
CONFIG_MTD_PARTITION=y
CONFIG_MTD_PROGMEM=y
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_LINELEN=64
CONFIG_NSH_READLINE=y
CONFIG_PREALLOC_TIMERS=4
CONFIG_RAM_SIZE=393216
CONFIG_RAM_START=0x20400000
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_SAMV7_APP_FORMAT_MCUBOOT=y
CONFIG_SAMV7_GPIOA_IRQ=y
CONFIG_SAMV7_GPIOC_IRQ=y
CONFIG_SAMV7_GPIO_IRQ=y
CONFIG_SAMV7_HSMCI0=y
CONFIG_SAMV7_PROGMEM=y
CONFIG_SAMV7_PROGMEM_NSECTORS=16
CONFIG_SAMV7_UART3=y
CONFIG_SAMV7_XDMAC=y
CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_WAITPID=y
CONFIG_SDCLONE_DISABLE=y
CONFIG_SDIO_BLOCKSETUP=y
CONFIG_START_DAY=10
CONFIG_START_MONTH=3
CONFIG_START_YEAR=2014
CONFIG_SYSTEM_I2CTOOL=y
CONFIG_SYSTEM_NSH=y
CONFIG_SYSTEM_RAMTEST=y
CONFIG_UART3_SERIAL_CONSOLE=y
CONFIG_USER_ENTRYPOINT="mcuboot_confirm_main"

View file

@ -0,0 +1,66 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_MMCSD_MMCSUPPORT is not set
# CONFIG_SAMV7_UART0 is not set
# CONFIG_SAMV7_UART2 is not set
# CONFIG_SAMV7_UART4 is not set
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="same70-qmtech"
CONFIG_ARCH_BOARD_SAME70_QMTECH=y
CONFIG_ARCH_CHIP="samv7"
CONFIG_ARCH_CHIP_SAME70=y
CONFIG_ARCH_CHIP_SAME70N19=y
CONFIG_ARCH_CHIP_SAME70N=y
CONFIG_ARCH_CHIP_SAMV7=y
CONFIG_ARCH_INTERRUPTSTACK=2048
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARMV7M_DCACHE=y
CONFIG_ARMV7M_ICACHE=y
CONFIG_ARMV7M_LAZYFPU=y
CONFIG_BOARD_LATE_INITIALIZE=y
CONFIG_BOARD_LOOPSPERMSEC=51262
CONFIG_BOOT_MCUBOOT=y
CONFIG_BUILTIN=y
CONFIG_FAT_LCNAMES=y
CONFIG_FAT_LFN=y
CONFIG_FS_FAT=y
CONFIG_FS_PROCFS=y
CONFIG_MCUBOOT_BOOTLOADER=y
CONFIG_MCUBOOT_ENABLE_LOGGING=y
CONFIG_MMCSD_MULTIBLOCK_DISABLE=y
CONFIG_MMCSD_SDIO=y
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_LINELEN=64
CONFIG_NSH_READLINE=y
CONFIG_PREALLOC_TIMERS=4
CONFIG_RAM_SIZE=262144
CONFIG_RAM_START=0x20400000
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_SAME70QMTECH_FORMAT_MCUBOOT=y
CONFIG_SAME70QMTECH_MCUBOOT_BOOTLOADER=y
CONFIG_SAMV7_GPIOA_IRQ=y
CONFIG_SAMV7_GPIOD_IRQ=y
CONFIG_SAMV7_GPIO_IRQ=y
CONFIG_SAMV7_HSMCI0=y
CONFIG_SAMV7_PROGMEM=y
CONFIG_SAMV7_USART1=y
CONFIG_SAMV7_XDMAC=y
CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_WAITPID=y
CONFIG_SDCLONE_DISABLE=y
CONFIG_SDIO_BLOCKSETUP=y
CONFIG_START_DAY=24
CONFIG_START_MONTH=11
CONFIG_START_YEAR=2021
CONFIG_SYSTEM_NSH=y
CONFIG_SYSTEM_RAMTEST=y
CONFIG_USART1_SERIAL_CONSOLE=y
CONFIG_USER_ENTRYPOINT="mcuboot_loader_main"

View file

@ -0,0 +1,62 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_ARCH_RAMFUNCS is not set
# CONFIG_MMCSD_MMCSUPPORT is not set
# CONFIG_SAMV7_UART0 is not set
# CONFIG_SAMV7_UART2 is not set
# CONFIG_SAMV7_UART4 is not set
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="same70-qmtech"
CONFIG_ARCH_BOARD_SAME70_QMTECH=y
CONFIG_ARCH_BUTTONS=y
CONFIG_ARCH_CHIP="samv7"
CONFIG_ARCH_CHIP_SAME70=y
CONFIG_ARCH_CHIP_SAME70N19=y
CONFIG_ARCH_CHIP_SAME70N=y
CONFIG_ARCH_CHIP_SAMV7=y
CONFIG_ARCH_INTERRUPTSTACK=2048
CONFIG_ARCH_IRQBUTTONS=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARMV7M_DCACHE=y
CONFIG_ARMV7M_ICACHE=y
CONFIG_ARMV7M_LAZYFPU=y
CONFIG_BOARD_LOOPSPERMSEC=51262
CONFIG_BUILTIN=y
CONFIG_FAT_LCNAMES=y
CONFIG_FAT_LFN=y
CONFIG_FS_FAT=y
CONFIG_FS_PROCFS=y
CONFIG_MMCSD_MULTIBLOCK_DISABLE=y
CONFIG_MMCSD_SDIO=y
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_LINELEN=64
CONFIG_NSH_READLINE=y
CONFIG_PREALLOC_TIMERS=4
CONFIG_RAM_SIZE=262144
CONFIG_RAM_START=0x20400000
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_SAMV7_GPIOA_IRQ=y
CONFIG_SAMV7_GPIOD_IRQ=y
CONFIG_SAMV7_GPIO_IRQ=y
CONFIG_SAMV7_HSMCI0=y
CONFIG_SAMV7_USART1=y
CONFIG_SAMV7_XDMAC=y
CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_WAITPID=y
CONFIG_SDCLONE_DISABLE=y
CONFIG_SDIO_BLOCKSETUP=y
CONFIG_START_DAY=27
CONFIG_START_MONTH=11
CONFIG_START_YEAR=2021
CONFIG_SYSTEM_NSH=y
CONFIG_SYSTEM_RAMTEST=y
CONFIG_USART1_SERIAL_CONSOLE=y
CONFIG_USER_ENTRYPOINT="nsh_main"

View file

@ -0,0 +1,367 @@
/****************************************************************************
* boards/arm/samv7/same70-qmtech/include/board.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __BOARDS_ARM_SAMV7_SAME70_QMTECH_INCLUDE_BOARD_H
#define __BOARDS_ARM_SAMV7_SAME70_QMTECH_INCLUDE_BOARD_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdbool.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Clocking *****************************************************************/
/* After power-on reset, the SAME70N device is running out of the Master
* Clock using the Fast RC Oscillator running at 4 MHz.
*
* MAINOSC: Frequency = 12MHz (crystal)
*
* 300MHz Settings:
* PLLA: PLL Divider = 1, Multiplier = 20 to generate PLLACK = 240MHz
* Master Clock (MCK): Source = PLLACK,
* Prescalar = 1 to generate MCK = 120MHz
* CPU clock: 120MHz
*
* There can be two on-board crystals. However, the 32.768 crystal is not
* populated on the stock SAME70. The fallback is to use th on-chip, slow RC
* oscillator which has a frequency of 22-42 KHz, nominally 32 KHz.
*/
#undef BOARD_HAVE_SLOWXTAL /* Slow crystal not populated */
#define BOARD_SLOWCLK_FREQUENCY (32000) /* 32 KHz RC oscillator (nominal) */
#define BOARD_MAINOSC_FREQUENCY (12000000) /* 12 MHz main oscillator */
/* Main oscillator register settings.
*
* The main oscillator could be either the embedded 4/8/12 MHz fast RC
* oscillators or an external 3-20 MHz crystal or ceramic resonator.
* The external clock source is selected by default in sam_clockconfig.c.
* Here we need to specify the main oscillator start-up time.
*
* REVISIT... this is old information:
* The start up time should be should be:
*
* Start Up Time = 8 * MOSCXTST / SLCK = 56 Slow Clock Cycles.
*/
#define BOARD_CKGR_MOR_MOSCXTST (62 << PMC_CKGR_MOR_MOSCXTST_SHIFT) /* Start-up Time */
#define BOARD_CKGR_MOR_MOSCXTENBY (PMC_CKGR_MOR_MOSCXTEN) /* Crystal Oscillator Enable */
/* PLLA configuration.
*
* Divider = 1
* Multiplier = 25
*
* Yields:
*
* PLLACK = 25 * 12MHz / 1 = 300MHz
*/
#define BOARD_CKGR_PLLAR_STMODE PMC_CKGR_PLLAR_STMODE_FAST
#define BOARD_CKGR_PLLAR_COUNT (63 << PMC_CKGR_PLLAR_COUNT_SHIFT)
#define BOARD_CKGR_PLLAR_MUL PMC_CKGR_PLLAR_MUL(24)
#define BOARD_CKGR_PLLAR_DIV PMC_CKGR_PLLAR_DIV_BYPASS
/* PMC master clock register settings.
*
* BOARD_PMC_MCKR_CSS - The source of main clock input. This may be one of:
*
* PMC_MCKR_CSS_SLOW Slow Clock
* PMC_MCKR_CSS_MAIN Main Clock
* PMC_MCKR_CSS_PLLA PLLA Clock
* PMC_MCKR_CSS_UPLL Divided UPLL Clock
*
* BOARD_PMC_MCKR_PRES - Source clock pre-scaler. May be one of:
*
* PMC_MCKR_PRES_DIV1 Selected clock
* PMC_MCKR_PRES_DIV2 Selected clock divided by 2
* PMC_MCKR_PRES_DIV4 Selected clock divided by 4
* PMC_MCKR_PRES_DIV8 Selected clock divided by 8
* PMC_MCKR_PRES_DIV16 Selected clock divided by 16
* PMC_MCKR_PRES_DIV32 Selected clock divided by 32
* PMC_MCKR_PRES_DIV64 Selected clock divided by 64
* PMC_MCKR_PRES_DIV3 Selected clock divided by 3
*
* The prescaler determines (1) the CPU clock and (2) the input into the
* second divider that then generates the Master Clock (MCK). MCK is the
* source clock of the peripheral clocks.
*
* BOARD_PMC_MCKR_MDIV - MCK divider. May be one of:
*
* PMC_MCKR_MDIV_DIV1 Master Clock = Prescaler Output Clock / 1
* PMC_MCKR_MDIV_DIV2 Master Clock = Prescaler Output Clock / 2
* PMC_MCKR_MDIV_DIV4 Master Clock = Prescaler Output Clock / 4
* PMC_MCKR_MDIV_DIV3 Master Clock = Prescaler Output Clock / 3
*/
#define BOARD_PMC_MCKR_CSS PMC_MCKR_CSS_PLLA /* Source = PLLA */
#define BOARD_PMC_MCKR_PRES PMC_MCKR_PRES_DIV1 /* Prescaler = /1 */
#define BOARD_PMC_MCKR_MDIV PMC_MCKR_MDIV_DIV2 /* MCK divider = /2 */
/* USB clocking */
#define BOARD_PMC_MCKR_UPLLDIV2 0 /* UPLL clock not divided by 2 */
/* Resulting frequencies */
#define BOARD_PLLA_FREQUENCY (300000000) /* PLLACK: 25 * 12Mhz / 1 */
#define BOARD_CPU_FREQUENCY (300000000) /* CPU: PLLACK / 1 */
#define BOARD_MCK_FREQUENCY (150000000) /* MCK: PLLACK / 1 / 2 */
#undef BOARD_UPLL_FREQUENCY /* To be provided */
/* HSMCI clocking
*
* Multimedia Card Interface clock (MCCK or MCI_CK) is Master Clock (MCK)
* divided by (2*(CLKDIV) + CLOCKODD + 2).
*
* MCI_SPEED = MCK / (2*CLKDIV + CLOCKODD + 2)
*
* Where CLKDIV has a range of 0-255.
*/
/* MCK = 150MHz, CLKDIV = 186,
* MCI_SPEED = 150MHz / (2*186 + 1 + 2) = 400 KHz
*/
#define HSMCI_INIT_CLKDIV ((186 << HSMCI_MR_CLKDIV_SHIFT) | HSMCI_MR_CLKODD)
/* MCK = 150MHz, CLKDIV = 3 w/CLOCKODD,
* MCI_SPEED = 150MHz /(2*3 + 0 + 2) = 18.75 MHz
*/
#define HSMCI_MMCXFR_CLKDIV (2 << HSMCI_MR_CLKDIV_SHIFT)
/* MCK = 150MHz, CLKDIV = 2,
* MCI_SPEED = 150MHz /(2*2 + 0 + 2) = 25 MHz
*/
#define HSMCI_SDXFR_CLKDIV (2 << HSMCI_MR_CLKDIV_SHIFT)
#define HSMCI_SDWIDEXFR_CLKDIV HSMCI_SDXFR_CLKDIV
/* FLASH wait states.
*
* Wait states Max frequency at 105 centigrade (STH conditions)
*
* VDDIO
* 1.62V 2.7V
* --- ------- -------
* 0 26 MHz 30 MHz
* 1 52 MHz 62 MHz
* 2 78 MHz 93 MHz
* 3 104 MHz 124 MHz
* 4 131 MHz 150 MHz
* 5 150 MHz --- MHz
*
* Given: VDDIO=3.3V, VDDCORE=1.2V, MCK=150MHz
*/
#define BOARD_FWS 4
/* LED definitions **********************************************************/
/* LEDs
*
* A single LED is available driven by PA15.
*/
/* LED index values for use with board_userled() */
#define BOARD_LED0 0
#define BOARD_NLEDS 1
/* LED bits for use with board_userled_all() */
#define BOARD_LED0_BIT (1 << BOARD_LED0)
/* This LED is not used by the board port unless CONFIG_ARCH_LEDS is
* defined. In that case, the usage by the board port is defined in
* include/board.h and src/sam_autoleds.c. The LEDs are used to encode
* OS-related events as follows:
*
* ------------------- ---------------------------- ------
* SYMBOL Meaning LED
* ------------------- ---------------------------- ------
*/
#define LED_STARTED 0 /* NuttX has been started OFF */
#define LED_HEAPALLOCATE 0 /* Heap has been allocated OFF */
#define LED_IRQSENABLED 0 /* Interrupts enabled OFF */
#define LED_STACKCREATED 1 /* Idle stack created ON */
#define LED_INIRQ 2 /* In an interrupt N/C */
#define LED_SIGNAL 2 /* In a signal handler N/C */
#define LED_ASSERTION 2 /* An assertion failed N/C */
#define LED_PANIC 3 /* The system has crashed FLASH */
#undef LED_IDLE /* MCU is is sleep mode Not used */
/* Thus is LED is statically on, NuttX has successfully booted and is,
* apparently, running normally. If LED is flashing at approximately
* 2Hz, then a fatal error has been detected and the system has halted.
*/
/* Button definitions *******************************************************/
/* Buttons
*
* SAM E70 QMTECH contains two mechanical buttons. One button is the RESET
* button connected to the SAM E70 reset line and the other, PA21, is a
* generic user configurable button.
* When a button is pressed it will drive the I/O line to GND.
*
* NOTE:
* There are no pull-up resistors connected to the generic user buttons
* so it is necessary to enable the internal pull-up in the SAM E70 to
* use the button.
*/
#define BUTTON_SW0 0
#define NUM_BUTTONS 1
#define BUTTON_SW0_BIT (1 << BUTTON_SW0)
/* PIO Disambiguation *******************************************************/
/* Serial Console
*
* The SAME70-QMTECH has no on-board RS-232 drivers so it will be necessary
* to use either the VCOM or an external RS-232 driver.
* Here are some options.
*
* - Arduino Serial Shield: One option is to use an Arduino-compatible
* serial shield. This will use the RXD and TXD signals available at pins
* 0 an 1, respectively, of the Arduino "Digital Low" connector. On the
* SAME70-QMTECH board, this corresponds to UART3:
*
* ------ ------ ------- ------- --------
* Pin on SAME70 Arduino Arduino SAME70
* J503 PIO Name Pin Function
* ------ ------ ------- ------- --------
* 1 PD28 RX0 0 URXD3
* 2 PD30 TX0 1 UTXD3
* ------ ------ ------- ------- --------
*
* There are alternative pin selections only for UART3 TXD:
*/
#define GPIO_UART3_TXD GPIO_UART3_TXD_1
/* - Arduino Communications. Additional UART/USART connections are available
* on the Arduino Communications connection J505:
*
* ------ ------ ------- ------- --------
* Pin on SAME70 Arduino Arduino SAME70
* J503 PIO Name Pin Function
* ------ ------ ------- ------- --------
* 3 PD18 RX1 0 URXD4
* 4 PD19 TX1 0 UTXD4
* 5 PD15 RX2 0 RXD2
* 6 PD16 TX2 0 TXD2
* 7 PB0 RX3 0 RXD0
* 8 PB1 TX3 1 TXD0
* ------ ------ ------- ------- --------
*
* There are alternative pin selections only for UART4 TXD:
*/
#define GPIO_UART4_TXD GPIO_UART4_TXD_1
/* - SAMV7-XULT EXTn connectors. USART pins are also available the EXTn
* connectors. The following are labelled in the User Guide for USART
* functionality:
*
* ---- -------- ------ --------
* EXT1 EXTI1 SAME70 SAME70
* Pin Name PIO Function
* ---- -------- ------ --------
* 13 USART_RX PB00 RXD0
* 14 USART_TX PB01 TXD0
*
* ---- -------- ------ --------
* EXT2 EXTI2 SAME70 SAME70
* Pin Name PIO Function
* ---- -------- ------ --------
* 13 USART_RX PA21 RXD1
* 14 USART_TX PB04 TXD1
*
* There are no alternative pin selections for USART0 or USART1.
*/
/* - VCOM. The Virtual Com Port gateway is available on USART1:
*
* ------ --------
* SAME70 SAME70
* PIO Function
* ------ --------
* PB04 TXD1
* PA21 RXD1
* ------ --------
*
* There are no alternative pin selections for USART1.
*/
/****************************************************************************
* Public Types
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
#ifndef __ASSEMBLY__
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Functions Definitions
****************************************************************************/
/****************************************************************************
* Name: sam_lcdclear
*
* Description:
* This is a non-standard LCD interface just for the SAM4e-EK board.
* Because of the various rotations, clearing the display in the normal
* way by writing a sequences of runs that covers the entire display can
* be very slow. Here the display is cleared by simply setting all GRAM
* memory to the specified color.
*
****************************************************************************/
void sam_lcdclear(uint16_t color);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __BOARDS_ARM_SAMV7_SAME70_QMTECH_INCLUDE_BOARD_H */

View file

@ -0,0 +1,103 @@
############################################################################
# boards/arm/samv7/same70-qmtech/kernel/Makefile
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
include $(TOPDIR)/Make.defs
# The entry point name (if none is provided in the .config file)
CONFIG_USER_ENTRYPOINT ?= user_start
ENTRYPT = $(patsubst "%",%,$(CONFIG_USER_ENTRYPOINT))
# Get the paths to the libraries and the links script path in format that
# is appropriate for the host OS
ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
# Windows-native toolchains
USER_LIBPATHS = ${shell for path in $(USERLIBS); do dir=`dirname $(TOPDIR)$(DELIM)$$path`;echo "-L\"`cygpath -w $$dir`\"";done}
USER_LDSCRIPT = -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)memory.ld}"
USER_LDSCRIPT += -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)user-space.ld}"
USER_HEXFILE += "${shell cygpath -w $(TOPDIR)$(DELIM)nuttx_user.hex}"
USER_SRECFILE += "${shell cygpath -w $(TOPDIR)$(DELIM)nuttx_user.srec}"
USER_BINFILE += "${shell cygpath -w $(TOPDIR)$(DELIM)nuttx_user.bin}"
else
# Linux/Cygwin-native toolchain
USER_LIBPATHS = $(addprefix -L$(TOPDIR)$(DELIM),$(dir $(USERLIBS)))
USER_LDSCRIPT = -T$(BOARD_DIR)$(DELIM)scripts$(DELIM)memory.ld
USER_LDSCRIPT += -T$(BOARD_DIR)$(DELIM)scripts$(DELIM)user-space.ld
USER_HEXFILE += "$(TOPDIR)$(DELIM)nuttx_user.hex"
USER_SRECFILE += "$(TOPDIR)$(DELIM)nuttx_user.srec"
USER_BINFILE += "$(TOPDIR)$(DELIM)nuttx_user.bin"
endif
USER_LDFLAGS = --undefined=$(ENTRYPT) --entry=$(ENTRYPT) $(USER_LDSCRIPT)
USER_LDLIBS = $(patsubst lib%,-l%,$(basename $(notdir $(USERLIBS))))
USER_LIBGCC = "${shell "$(CC)" $(ARCHCPUFLAGS) -print-libgcc-file-name}"
# Source files
CSRCS = sam_userspace.c
COBJS = $(CSRCS:.c=$(OBJEXT))
OBJS = $(COBJS)
# Targets:
all: $(TOPDIR)$(DELIM)nuttx_user.elf $(TOPDIR)$(DELIM)User.map
.PHONY: nuttx_user.elf depend clean distclean
$(COBJS): %$(OBJEXT): %.c
$(call COMPILE, $<, $@)
# Create the nuttx_user.elf file containing all of the user-mode code
nuttx_user.elf: $(OBJS)
$(Q) $(LD) -o $@ $(USER_LDFLAGS) $(USER_LIBPATHS) $(OBJS) --start-group $(USER_LDLIBS) --end-group $(USER_LIBGCC)
$(TOPDIR)$(DELIM)nuttx_user.elf: nuttx_user.elf
@echo "LD: nuttx_user.elf"
$(Q) cp -a nuttx_user.elf $(TOPDIR)$(DELIM)nuttx_user.elf
ifeq ($(CONFIG_INTELHEX_BINARY),y)
@echo "CP: nuttx_user.hex"
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O ihex nuttx_user.elf $(USER_HEXFILE)
endif
ifeq ($(CONFIG_MOTOROLA_SREC),y)
@echo "CP: nuttx_user.srec"
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O srec nuttx_user.elf $(USER_SRECFILE)
endif
ifeq ($(CONFIG_RAW_BINARY),y)
@echo "CP: nuttx_user.bin"
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O binary nuttx_user.elf $(USER_BINFILE)
endif
$(TOPDIR)$(DELIM)User.map: nuttx_user.elf
@echo "MK: User.map"
$(Q) $(NM) nuttx_user.elf >$(TOPDIR)$(DELIM)User.map
$(Q) $(CROSSDEV)size nuttx_user.elf
.depend:
depend: .depend
clean:
$(call DELFILE, nuttx_user.elf)
$(call DELFILE, "$(TOPDIR)$(DELIM)nuttx_user.*")
$(call DELFILE, "$(TOPDIR)$(DELIM)User.map")
$(call CLEAN)
distclean: clean

View file

@ -0,0 +1,113 @@
/****************************************************************************
* boards/arm/samv7/same70-qmtech/kernel/sam_userspace.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdlib.h>
#include <nuttx/userspace.h>
#include <nuttx/wqueue.h>
#include <nuttx/mm/mm.h>
#if defined(CONFIG_BUILD_PROTECTED) && !defined(__KERNEL__)
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
#ifndef CONFIG_NUTTX_USERSPACE
# error "CONFIG_NUTTX_USERSPACE not defined"
#endif
#if CONFIG_NUTTX_USERSPACE != 0x00440000
# error "CONFIG_NUTTX_USERSPACE must be 0x00440000 to match user-space.ld"
#endif
/****************************************************************************
* Public Data
****************************************************************************/
/* These 'addresses' of these values are setup by the linker script.
* They are not actual uint32_t storage locations!
* They are only used meaningfully in the following way:
*
* - The linker script defines, for example, the symbol_sdata.
* - The declareion extern uint32_t _sdata; makes C happy. C will believe
* that the value _sdata is the address of a uint32_t variable _data (it
* is not!).
* - We can recoved the linker value then by simply taking the address of
* of _data. like: uint32_t *pdata = &_sdata;
*/
extern uint32_t _stext; /* Start of .text */
extern uint32_t _etext; /* End_1 of .text + .rodata */
extern const uint32_t _eronly; /* End+1 of read only section (.text + .rodata) */
extern uint32_t _sdata; /* Start of .data */
extern uint32_t _edata; /* End+1 of .data */
extern uint32_t _sbss; /* Start of .bss */
extern uint32_t _ebss; /* End+1 of .bss */
/* This is the user space entry point */
int CONFIG_USER_ENTRYPOINT(int argc, char *argv[]);
const struct userspace_s userspace locate_data(".userspace") =
{
/* General memory map */
.us_entrypoint = (main_t)CONFIG_USER_ENTRYPOINT,
.us_textstart = (uintptr_t)&_stext,
.us_textend = (uintptr_t)&_etext,
.us_datasource = (uintptr_t)&_eronly,
.us_datastart = (uintptr_t)&_sdata,
.us_dataend = (uintptr_t)&_edata,
.us_bssstart = (uintptr_t)&_sbss,
.us_bssend = (uintptr_t)&_ebss,
/* Memory manager heap structure */
.us_heap = &g_mmheap,
/* Task/thread startup routines */
.task_startup = nxtask_startup,
/* Signal handler trampoline */
.signal_handler = up_signal_handler,
/* User-space work queue support (declared in include/nuttx/wqueue.h) */
#ifdef CONFIG_LIBC_USRWORK
.work_usrstart = work_usrstart,
#endif
};
/****************************************************************************
* Public Functions
****************************************************************************/
#endif /* CONFIG_BUILD_PROTECTED && !__KERNEL__ */

View file

@ -0,0 +1,85 @@
############################################################################
# boards/arm/samv7/same70-qmtech/scripts/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
include $(TOPDIR)/.config
include $(TOPDIR)/tools/Config.mk
include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs
ifeq ($(CONFIG_ARMV7M_DTCM),y)
LDSCRIPT_PREFIX = flash-dtcm
else
LDSCRIPT_PREFIX = flash-sram
endif
ifeq ($(CONFIG_SAME70QMTECH_FORMAT_MCUBOOT),y)
ifeq ($(CONFIG_SAME70QMTECH_MCUBOOT_BOOTLOADER),y)
LDSCRIPT = $(LDSCRIPT_PREFIX)-mcuboot-loader.ld
else
LDSCRIPT = $(LDSCRIPT_PREFIX)-mcuboot-app.ld
endif
else
LDSCRIPT = $(LDSCRIPT_PREFIX).ld
endif
ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
ARCHSCRIPT = -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}"
else
ARCHSCRIPT = -T$(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
endif
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION = -g
endif
ifneq ($(CONFIG_DEBUG_NOOPT),y)
ARCHOPTIMIZATION += $(MAXOPTIMIZATION)
endif
ARCHCFLAGS = -fno-builtin
ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fcheck-new -fno-rtti
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -fno-strict-aliasing
ARCHWARNINGSXX = -Wall -Wshadow -Wundef
ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe
CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS)
CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe
CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
AFLAGS := $(CFLAGS) -D__ASSEMBLY__
NXFLATLDFLAGS1 = -r -d -warn-common
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
LDNXFLATFLAGS = -e main -s 2048
# Loadable module definitions
CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
LDMODULEFLAGS = -r -e module_initialize
ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
LDMODULEFLAGS += -T "${shell cygpath -w $(TOPDIR)/libs/libc/modlib/gnu-elf.ld}"
else
LDMODULEFLAGS += -T $(TOPDIR)/libs/libc/modlib/gnu-elf.ld
endif
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
LDFLAGS += -g
endif

View file

@ -0,0 +1,12 @@
#
# Atmel SAME70 QMTECH board.
# https://github.com/ChinaQMTECH/ATSAMS70_E70
#
# Connect using the EDBG chip on the dev kit over USB
source [find interface/cmsis-dap.cfg]
set CHIPNAME atsame70n19
source [find target/atsamv.cfg]
reset_config srst_only

View file

@ -0,0 +1,117 @@
/****************************************************************************
* boards/arm/samv7/same70-qmtech/scripts/flash-dtcm-mcuboot-app.ld
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/* The SAME70N19 has 512Kb of FLASH beginning at address 0x0040:0000 and
* 256Kb of SRAM beginining at 0x2040:0000
*
* When booting from FLASH, FLASH memory is aliased to address 0x0000:0000
* where the code expects to begin execution by jumping to the entry point in
* the 0x0400:0000 address range (Assuming that ITCM is not enable).
*
* NOTE: that the DTCM address of 0x2000:0000 is used for SRAM. If DTCM is
* disabled, then the accesses will actually occur on the AHB bus.
*/
MEMORY
{
flash (rx) : ORIGIN = 0x00420200, LENGTH = 160K - 0x200
sram (rwx) : ORIGIN = 0x20000000, LENGTH = 256K
}
OUTPUT_ARCH(arm)
EXTERN(_vectors)
ENTRY(_stext)
SECTIONS
{
.text : {
_stext = ABSOLUTE(.);
*(.vectors)
*(.text .text.*)
*(.fixup)
*(.gnu.warning)
*(.rodata .rodata.*)
*(.gnu.linkonce.t.*)
*(.glue_7)
*(.glue_7t)
*(.got)
*(.gcc_except_table)
*(.gnu.linkonce.r.*)
_etext = ABSOLUTE(.);
} > flash
.init_section : {
_sinit = ABSOLUTE(.);
*(.init_array .init_array.*)
_einit = ABSOLUTE(.);
} > flash
.ARM.extab : {
*(.ARM.extab*)
} > flash
__exidx_start = ABSOLUTE(.);
.ARM.exidx : {
*(.ARM.exidx*)
} > flash
__exidx_end = ABSOLUTE(.);
_eronly = ABSOLUTE(.);
.data : {
_sdata = ABSOLUTE(.);
*(.data .data.*)
*(.gnu.linkonce.d.*)
CONSTRUCTORS
. = ALIGN(4);
_edata = ABSOLUTE(.);
} > sram AT > flash
.ramfunc ALIGN(4): {
_sramfuncs = ABSOLUTE(.);
*(.ramfunc .ramfunc.*)
_eramfuncs = ABSOLUTE(.);
} > sram AT > flash
_framfuncs = LOADADDR(.ramfunc);
.bss : {
_sbss = ABSOLUTE(.);
*(.bss .bss.*)
*(.gnu.linkonce.b.*)
*(COMMON)
. = ALIGN(4);
_ebss = ABSOLUTE(.);
} > sram
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_info 0 : { *(.debug_info) }
.debug_line 0 : { *(.debug_line) }
.debug_pubnames 0 : { *(.debug_pubnames) }
.debug_aranges 0 : { *(.debug_aranges) }
}

View file

@ -0,0 +1,117 @@
/****************************************************************************
* boards/arm/samv7/same70-qmtech/scripts/flash-dtcm-mcuboot-loader.ld
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/* The SAME70N19 has 512Kb of FLASH beginning at address 0x0040:0000 and
* 256Kb of SRAM beginining at 0x2040:0000
*
* When booting from FLASH, FLASH memory is aliased to address 0x0000:0000
* where the code expects to begin execution by jumping to the entry point in
* the 0x0400:0000 address range (Assuming that ITCM is not enable).
*
* NOTE: that the DTCM address of 0x2000:0000 is used for SRAM. If DTCM is
* disabled, then the accesses will actually occur on the AHB bus.
*/
MEMORY
{
flash (rx) : ORIGIN = 0x00400000, LENGTH = 128K
sram (rwx) : ORIGIN = 0x20000000, LENGTH = 256K
}
OUTPUT_ARCH(arm)
EXTERN(_vectors)
ENTRY(_stext)
SECTIONS
{
.text : {
_stext = ABSOLUTE(.);
*(.vectors)
*(.text .text.*)
*(.fixup)
*(.gnu.warning)
*(.rodata .rodata.*)
*(.gnu.linkonce.t.*)
*(.glue_7)
*(.glue_7t)
*(.got)
*(.gcc_except_table)
*(.gnu.linkonce.r.*)
_etext = ABSOLUTE(.);
} > flash
.init_section : {
_sinit = ABSOLUTE(.);
*(.init_array .init_array.*)
_einit = ABSOLUTE(.);
} > flash
.ARM.extab : {
*(.ARM.extab*)
} > flash
__exidx_start = ABSOLUTE(.);
.ARM.exidx : {
*(.ARM.exidx*)
} > flash
__exidx_end = ABSOLUTE(.);
_eronly = ABSOLUTE(.);
.data : {
_sdata = ABSOLUTE(.);
*(.data .data.*)
*(.gnu.linkonce.d.*)
CONSTRUCTORS
. = ALIGN(4);
_edata = ABSOLUTE(.);
} > sram AT > flash
.ramfunc ALIGN(4): {
_sramfuncs = ABSOLUTE(.);
*(.ramfunc .ramfunc.*)
_eramfuncs = ABSOLUTE(.);
} > sram AT > flash
_framfuncs = LOADADDR(.ramfunc);
.bss : {
_sbss = ABSOLUTE(.);
*(.bss .bss.*)
*(.gnu.linkonce.b.*)
*(COMMON)
. = ALIGN(4);
_ebss = ABSOLUTE(.);
} > sram
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_info 0 : { *(.debug_info) }
.debug_line 0 : { *(.debug_line) }
.debug_pubnames 0 : { *(.debug_pubnames) }
.debug_aranges 0 : { *(.debug_aranges) }
}

View file

@ -0,0 +1,117 @@
/****************************************************************************
* boards/arm/samv7/same70-qmtech/scripts/flash-dtcm.ld
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/* The SAME70N19 has 512Kb of FLASH beginning at address 0x0040:0000 and
* 256Kb of SRAM beginining at 0x2040:0000
*
* When booting from FLASH, FLASH memory is aliased to address 0x0000:0000
* where the code expects to begin execution by jumping to the entry point in
* the 0x0400:0000 address range (Assuming that ITCM is not enable).
*
* NOTE: that the DTCM address of 0x2000:0000 is used for SRAM. If DTCM is
* disabled, then the accesses will actually occur on the AHB bus.
*/
MEMORY
{
flash (rx) : ORIGIN = 0x00400000, LENGTH = 512K
sram (rwx) : ORIGIN = 0x20000000, LENGTH = 256K
}
OUTPUT_ARCH(arm)
EXTERN(_vectors)
ENTRY(_stext)
SECTIONS
{
.text : {
_stext = ABSOLUTE(.);
*(.vectors)
*(.text .text.*)
*(.fixup)
*(.gnu.warning)
*(.rodata .rodata.*)
*(.gnu.linkonce.t.*)
*(.glue_7)
*(.glue_7t)
*(.got)
*(.gcc_except_table)
*(.gnu.linkonce.r.*)
_etext = ABSOLUTE(.);
} > flash
.init_section : {
_sinit = ABSOLUTE(.);
*(.init_array .init_array.*)
_einit = ABSOLUTE(.);
} > flash
.ARM.extab : {
*(.ARM.extab*)
} > flash
__exidx_start = ABSOLUTE(.);
.ARM.exidx : {
*(.ARM.exidx*)
} > flash
__exidx_end = ABSOLUTE(.);
_eronly = ABSOLUTE(.);
.data : {
_sdata = ABSOLUTE(.);
*(.data .data.*)
*(.gnu.linkonce.d.*)
CONSTRUCTORS
. = ALIGN(4);
_edata = ABSOLUTE(.);
} > sram AT > flash
.ramfunc ALIGN(4): {
_sramfuncs = ABSOLUTE(.);
*(.ramfunc .ramfunc.*)
_eramfuncs = ABSOLUTE(.);
} > sram AT > flash
_framfuncs = LOADADDR(.ramfunc);
.bss : {
_sbss = ABSOLUTE(.);
*(.bss .bss.*)
*(.gnu.linkonce.b.*)
*(COMMON)
. = ALIGN(4);
_ebss = ABSOLUTE(.);
} > sram
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_info 0 : { *(.debug_info) }
.debug_line 0 : { *(.debug_line) }
.debug_pubnames 0 : { *(.debug_pubnames) }
.debug_aranges 0 : { *(.debug_aranges) }
}

View file

@ -0,0 +1,114 @@
/****************************************************************************
* boards/arm/samv7/same70-qmtech/scripts/flash-sram-mcuboot-app.ld
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/* The SAME70N19 has 512Kb of FLASH beginning at address 0x0040:0000 and
* 256Kb of SRAM beginining at 0x2040:0000
*
* When booting from FLASH, FLASH memory is aliased to address 0x0000:0000
* where the code expects to begin execution by jumping to the entry point in
* the 0x0400:0000 address range (Assuming that ITCM is not enable).
*/
MEMORY
{
flash (rx) : ORIGIN = 0x00420200, LENGTH = 160K - 0x200
sram (rwx) : ORIGIN = 0x20400000, LENGTH = 256K
}
OUTPUT_ARCH(arm)
EXTERN(_vectors)
ENTRY(_stext)
SECTIONS
{
.text : {
_stext = ABSOLUTE(.);
*(.vectors)
*(.text .text.*)
*(.fixup)
*(.gnu.warning)
*(.rodata .rodata.*)
*(.gnu.linkonce.t.*)
*(.glue_7)
*(.glue_7t)
*(.got)
*(.gcc_except_table)
*(.gnu.linkonce.r.*)
_etext = ABSOLUTE(.);
} > flash
.init_section : {
_sinit = ABSOLUTE(.);
*(.init_array .init_array.*)
_einit = ABSOLUTE(.);
} > flash
.ARM.extab : {
*(.ARM.extab*)
} > flash
__exidx_start = ABSOLUTE(.);
.ARM.exidx : {
*(.ARM.exidx*)
} > flash
__exidx_end = ABSOLUTE(.);
_eronly = ABSOLUTE(.);
.data : {
_sdata = ABSOLUTE(.);
*(.data .data.*)
*(.gnu.linkonce.d.*)
CONSTRUCTORS
. = ALIGN(4);
_edata = ABSOLUTE(.);
} > sram AT > flash
.ramfunc ALIGN(4): {
_sramfuncs = ABSOLUTE(.);
*(.ramfunc .ramfunc.*)
_eramfuncs = ABSOLUTE(.);
} > sram AT > flash
_framfuncs = LOADADDR(.ramfunc);
.bss : {
_sbss = ABSOLUTE(.);
*(.bss .bss.*)
*(.gnu.linkonce.b.*)
*(COMMON)
. = ALIGN(4);
_ebss = ABSOLUTE(.);
} > sram
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_info 0 : { *(.debug_info) }
.debug_line 0 : { *(.debug_line) }
.debug_pubnames 0 : { *(.debug_pubnames) }
.debug_aranges 0 : { *(.debug_aranges) }
}

View file

@ -0,0 +1,114 @@
/****************************************************************************
* boards/arm/samv7/same70-qmtech/scripts/flash-sram-mcuboot-loader.ld
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/* The SAME70N19 has 512Kb of FLASH beginning at address 0x0040:0000 and
* 256Kb of SRAM beginining at 0x2040:0000
*
* When booting from FLASH, FLASH memory is aliased to address 0x0000:0000
* where the code expects to begin execution by jumping to the entry point in
* the 0x0400:0000 address range (Assuming that ITCM is not enable).
*/
MEMORY
{
flash (rx) : ORIGIN = 0x00400000, LENGTH = 128K
sram (rwx) : ORIGIN = 0x20400000, LENGTH = 256K
}
OUTPUT_ARCH(arm)
EXTERN(_vectors)
ENTRY(_stext)
SECTIONS
{
.text : {
_stext = ABSOLUTE(.);
*(.vectors)
*(.text .text.*)
*(.fixup)
*(.gnu.warning)
*(.rodata .rodata.*)
*(.gnu.linkonce.t.*)
*(.glue_7)
*(.glue_7t)
*(.got)
*(.gcc_except_table)
*(.gnu.linkonce.r.*)
_etext = ABSOLUTE(.);
} > flash
.init_section : {
_sinit = ABSOLUTE(.);
*(.init_array .init_array.*)
_einit = ABSOLUTE(.);
} > flash
.ARM.extab : {
*(.ARM.extab*)
} > flash
__exidx_start = ABSOLUTE(.);
.ARM.exidx : {
*(.ARM.exidx*)
} > flash
__exidx_end = ABSOLUTE(.);
_eronly = ABSOLUTE(.);
.data : {
_sdata = ABSOLUTE(.);
*(.data .data.*)
*(.gnu.linkonce.d.*)
CONSTRUCTORS
. = ALIGN(4);
_edata = ABSOLUTE(.);
} > sram AT > flash
.ramfunc ALIGN(4): {
_sramfuncs = ABSOLUTE(.);
*(.ramfunc .ramfunc.*)
_eramfuncs = ABSOLUTE(.);
} > sram AT > flash
_framfuncs = LOADADDR(.ramfunc);
.bss : {
_sbss = ABSOLUTE(.);
*(.bss .bss.*)
*(.gnu.linkonce.b.*)
*(COMMON)
. = ALIGN(4);
_ebss = ABSOLUTE(.);
} > sram
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_info 0 : { *(.debug_info) }
.debug_line 0 : { *(.debug_line) }
.debug_pubnames 0 : { *(.debug_pubnames) }
.debug_aranges 0 : { *(.debug_aranges) }
}

View file

@ -0,0 +1,114 @@
/****************************************************************************
* boards/arm/samv7/same70-qmtech/scripts/flash-sram.ld
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/* The SAME70N19 has 512Kb of FLASH beginning at address 0x0040:0000 and
* 256Kb of SRAM beginining at 0x2040:0000
*
* When booting from FLASH, FLASH memory is aliased to address 0x0000:0000
* where the code expects to begin execution by jumping to the entry point in
* the 0x0400:0000 address range (Assuming that ITCM is not enable).
*/
MEMORY
{
flash (rx) : ORIGIN = 0x00400000, LENGTH = 512K
sram (rwx) : ORIGIN = 0x20400000, LENGTH = 256K
}
OUTPUT_ARCH(arm)
EXTERN(_vectors)
ENTRY(_stext)
SECTIONS
{
.text : {
_stext = ABSOLUTE(.);
*(.vectors)
*(.text .text.*)
*(.fixup)
*(.gnu.warning)
*(.rodata .rodata.*)
*(.gnu.linkonce.t.*)
*(.glue_7)
*(.glue_7t)
*(.got)
*(.gcc_except_table)
*(.gnu.linkonce.r.*)
_etext = ABSOLUTE(.);
} > flash
.init_section : {
_sinit = ABSOLUTE(.);
*(.init_array .init_array.*)
_einit = ABSOLUTE(.);
} > flash
.ARM.extab : {
*(.ARM.extab*)
} > flash
__exidx_start = ABSOLUTE(.);
.ARM.exidx : {
*(.ARM.exidx*)
} > flash
__exidx_end = ABSOLUTE(.);
_eronly = ABSOLUTE(.);
.data : {
_sdata = ABSOLUTE(.);
*(.data .data.*)
*(.gnu.linkonce.d.*)
CONSTRUCTORS
. = ALIGN(4);
_edata = ABSOLUTE(.);
} > sram AT > flash
.ramfunc ALIGN(4): {
_sramfuncs = ABSOLUTE(.);
*(.ramfunc .ramfunc.*)
_eramfuncs = ABSOLUTE(.);
} > sram AT > flash
_framfuncs = LOADADDR(.ramfunc);
.bss : {
_sbss = ABSOLUTE(.);
*(.bss .bss.*)
*(.gnu.linkonce.b.*)
*(COMMON)
. = ALIGN(4);
_ebss = ABSOLUTE(.);
} > sram
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_info 0 : { *(.debug_info) }
.debug_line 0 : { *(.debug_line) }
.debug_pubnames 0 : { *(.debug_pubnames) }
.debug_aranges 0 : { *(.debug_aranges) }
}

View file

@ -0,0 +1,115 @@
/****************************************************************************
* boards/arm/samv7/same70-qmtech/scripts/gnu-elf.ld
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
SECTIONS
{
.text 0x00000000 :
{
_stext = . ;
*(.text)
*(.text.*)
*(.gnu.warning)
*(.stub)
*(.glue_7)
*(.glue_7t)
*(.jcr)
/* C++ support: The .init and .fini sections contain specific logic
* to manage static constructors and destructors.
*/
*(.gnu.linkonce.t.*)
*(.init) /* Old ABI */
*(.fini) /* Old ABI */
_etext = . ;
}
.rodata :
{
_srodata = . ;
*(.rodata)
*(.rodata1)
*(.rodata.*)
*(.gnu.linkonce.r*)
_erodata = . ;
}
.data :
{
_sdata = . ;
*(.data)
*(.data1)
*(.data.*)
*(.gnu.linkonce.d*)
. = ALIGN(4);
_edata = . ;
}
/* C++ support. For each global and static local C++ object,
* GCC creates a small subroutine to construct the object. Pointers
* to these routines (not the routines themselves) are stored as
* simple, linear arrays in the .ctors section of the object file.
* Similarly, pointers to global/static destructor routines are
* stored in .dtors.
*/
.ctors :
{
_sctors = . ;
*(.ctors) /* Old ABI: Unallocated */
*(.init_array) /* New ABI: Allocated */
_edtors = . ;
}
.dtors :
{
_sdtors = . ;
*(.dtors) /* Old ABI: Unallocated */
*(.fini_array) /* New ABI: Allocated */
_edtors = . ;
}
.bss :
{
_sbss = . ;
*(.bss)
*(.bss.*)
*(.sbss)
*(.sbss.*)
*(.gnu.linkonce.b*)
*(COMMON)
_ebss = . ;
}
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_info 0 : { *(.debug_info) }
.debug_line 0 : { *(.debug_line) }
.debug_pubnames 0 : { *(.debug_pubnames) }
.debug_aranges 0 : { *(.debug_aranges) }
}

View file

@ -0,0 +1,106 @@
/****************************************************************************
* boards/arm/samv7/same70-qmtech/scripts/kernel-space.ld
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/* NOTE: This depends on the memory.ld script having been included prior to
* this script.
*/
OUTPUT_ARCH(arm)
EXTERN(_vectors)
ENTRY(_stext)
SECTIONS
{
.text : {
_stext = ABSOLUTE(.);
*(.vectors)
*(.text .text.*)
*(.fixup)
*(.gnu.warning)
*(.rodata .rodata.*)
*(.gnu.linkonce.t.*)
*(.glue_7)
*(.glue_7t)
*(.got)
*(.gcc_except_table)
*(.gnu.linkonce.r.*)
_etext = ABSOLUTE(.);
} > kflash
.init_section : {
_sinit = ABSOLUTE(.);
*(.init_array .init_array.*)
_einit = ABSOLUTE(.);
} > kflash
.ARM.extab : {
*(.ARM.extab*)
} > kflash
__exidx_start = ABSOLUTE(.);
.ARM.exidx : {
*(.ARM.exidx*)
} > kflash
__exidx_end = ABSOLUTE(.);
_eronly = ABSOLUTE(.);
.data : {
_sdata = ABSOLUTE(.);
*(.data .data.*)
*(.gnu.linkonce.d.*)
CONSTRUCTORS
. = ALIGN(4);
_edata = ABSOLUTE(.);
} > ksram AT > kflash
.ramfunc ALIGN(4): {
_sramfuncs = ABSOLUTE(.);
*(.ramfunc .ramfunc.*)
_eramfuncs = ABSOLUTE(.);
} > ksram AT > kflash
_framfuncs = LOADADDR(.ramfunc);
.bss : {
_sbss = ABSOLUTE(.);
*(.bss .bss.*)
*(.gnu.linkonce.b.*)
*(COMMON)
. = ALIGN(4);
_ebss = ABSOLUTE(.);
} > ksram
/* Stabs debugging sections */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_info 0 : { *(.debug_info) }
.debug_line 0 : { *(.debug_line) }
.debug_pubnames 0 : { *(.debug_pubnames) }
.debug_aranges 0 : { *(.debug_aranges) }
}

View file

@ -0,0 +1,66 @@
/****************************************************************************
* boards/arm/samv7/same70-qmtech/scripts/memory.ld
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/* The SAME70N19 has 512Kb of FLASH beginning at address 0x0040:0000 and
* 256Kb of SRAM beginining at 0x2040:0000
*
* When booting from FLASH, FLASH memory is aliased to address 0x0000:0000
* where the code expects to begin execution by jumping to the entry point in
* the 0x0400:0000 address range.
*
* The user space partition will be spanned with a single region of size
* 2**n bytes. The alignment of the user-space region must be the same.
* As a consequence, as the user-space increases in size, the alignment
* requirement also increases. The sizes below give the largest possible
* user address spaces (but leave far too much for the OS).
*
* The solution to this wasted memory is to (1) use more than one region to
* span the user spaces, or (2) poke holes in a larger region to trim it
* to fit better.
*
* A detailed memory map for the 256KB SRAM region is as follows:
*
* 0x2040 0000: Kernel .data region. Typical size: 0.1KB
* ------ ---- Kernel .bss region. Typical size: 1.8KB
* 0x2040 0800: Kernel IDLE thread stack (approximate). Size is
* determined by CONFIG_IDLETHREAD_STACKSIZE and
* adjustments for alignment. Typical is 1KB.
* ------ ---- Padded to 4KB
* 0x2041 0000: User .data region. Size is variable.
* ------- ---- User .bss region Size is variable.
* 0x2042 0000: Beginning of kernel heap. Size determined by
* CONFIG_MM_KERNEL_HEAPSIZE.
* ------ ---- Beginning of user heap. Can vary with other settings.
* 0x2044 0000: End+1 of mappable internal SRAM
*/
MEMORY
{
/* 512Kb of internal FLASH */
kflash (rx) : ORIGIN = 0x00400000, LENGTH = 256K
uflash (rx) : ORIGIN = 0x00440000, LENGTH = 256K
/* 256Kb of internal SRAM */
ksram (rwx) : ORIGIN = 0x20400000, LENGTH = 64K
usram (rwx) : ORIGIN = 0x20410000, LENGTH = 64K
xsram (rwx) : ORIGIN = 0x20420000, LENGTH = 128K
}

View file

@ -0,0 +1,111 @@
/****************************************************************************
* boards/arm/samv7/same70-qmtech/scripts/user-space.ld
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/* NOTE: This depends on the memory.ld script having been included prior to
* this script.
*/
/* Make sure that the critical memory management functions are in user-space.
* the user heap memory manager will reside in user-space but be usable both
* by kernel- and user-space code
*/
EXTERN(umm_initialize)
EXTERN(umm_addregion)
EXTERN(malloc)
EXTERN(realloc)
EXTERN(zalloc)
EXTERN(free)
OUTPUT_ARCH(arm)
SECTIONS
{
.userspace : {
*(.userspace)
} > uflash
.text : {
_stext = ABSOLUTE(.);
*(.text .text.*)
*(.fixup)
*(.gnu.warning)
*(.rodata .rodata.*)
*(.gnu.linkonce.t.*)
*(.glue_7)
*(.glue_7t)
*(.got)
*(.gcc_except_table)
*(.gnu.linkonce.r.*)
_etext = ABSOLUTE(.);
} > uflash
.init_section : {
_sinit = ABSOLUTE(.);
*(.init_array .init_array.*)
_einit = ABSOLUTE(.);
} > uflash
.ARM.extab : {
*(.ARM.extab*)
} > uflash
__exidx_start = ABSOLUTE(.);
.ARM.exidx : {
*(.ARM.exidx*)
} > uflash
__exidx_end = ABSOLUTE(.);
_eronly = ABSOLUTE(.);
.data : {
_sdata = ABSOLUTE(.);
*(.data .data.*)
*(.gnu.linkonce.d.*)
CONSTRUCTORS
. = ALIGN(4);
_edata = ABSOLUTE(.);
} > usram AT > uflash
.bss : {
_sbss = ABSOLUTE(.);
*(.bss .bss.*)
*(.gnu.linkonce.b.*)
*(COMMON)
. = ALIGN(4);
_ebss = ABSOLUTE(.);
} > usram
/* Stabs debugging sections */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_info 0 : { *(.debug_info) }
.debug_line 0 : { *(.debug_line) }
.debug_pubnames 0 : { *(.debug_pubnames) }
.debug_aranges 0 : { *(.debug_aranges) }
}

View file

@ -0,0 +1,71 @@
############################################################################
# boards/arm/samv7/same70-qmtech/src/Makefile
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
include $(TOPDIR)/Make.defs
CSRCS = sam_boot.c
ifeq ($(CONFIG_BOARDCTL),y)
CSRCS += sam_appinit.c sam_bringup.c sam_progmem.c
ifeq ($(CONFIG_BOARDCTL_RESET),y)
CSRCS += sam_reset.c
endif
ifeq ($(CONFIG_BOARDCTL_BOOT_IMAGE),y)
CSRCS += sam_boot_image.c
endif
else ifeq ($(CONFIG_BOARD_LATE_INITIALIZE),y)
CSRCS += sam_bringup.c sam_progmem.c
endif
ifeq ($(CONFIG_ARCH_LEDS),y)
CSRCS += sam_autoleds.c
else
CSRCS += sam_userleds.c
endif
ifeq ($(CONFIG_ARCH_BUTTONS),y)
CSRCS += sam_buttons.c
endif
ifeq ($(CONFIG_SAMV7_HSMCI0),y)
CSRCS += sam_hsmci.c
endif
ifeq ($(CONFIG_FS_AUTOMOUNTER),y)
CSRCS += sam_automount.c
endif
ifeq ($(CONFIG_SAMV7_SPI),y)
CSRCS += sam_spi.c
endif
ifeq ($(CONFIG_SAMV7_MCAN),y)
CSRCS += sam_mcan.c
endif
ifeq ($(CONFIG_SAMV7_AFEC),y)
CSRCS += sam_afec.c
endif
ifneq (,$(findstring y,$(CONFIG_SAMV7_DAC0) $(CONFIG_SAMV7_DAC1)))
CSRCS += sam_dac.c
endif
include $(TOPDIR)/boards/Board.mk

View file

@ -0,0 +1,121 @@
/****************************************************************************
* boards/arm/samv7/same70-qmtech/src/sam_afec.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/board.h>
#include <nuttx/analog/adc.h>
#include <arch/board/board.h>
#include "chip.h"
#include "arm_arch.h"
#include "sam_afec.h"
#include "same70-qmtech.h"
#ifdef CONFIG_SAMV7_AFEC
#define ADC0_NCHANNELS 3
#define ADC1_NCHANNELS 4
/****************************************************************************
* Private Data
****************************************************************************/
#ifdef CONFIG_SAMV7_AFEC0
static const uint8_t g_chanlist0[ADC0_NCHANNELS] =
{
0, 6, 8
};
#endif
#ifdef CONFIG_SAMV7_AFEC1
static const uint8_t g_chanlist1[ADC1_NCHANNELS] =
{
1, 3, 5, 6
};
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: sam_afecinitialize
*
* Description:
* Initialize and register the ADC driver.
*
****************************************************************************/
int sam_afec_setup(void)
{
struct adc_dev_s *adc;
int ret;
/* Call sam_adc_initialize() to get an instance of the ADC interface */
#ifdef CONFIG_SAMV7_AFEC0
adc = sam_afec_initialize(0, g_chanlist0, ADC0_NCHANNELS);
if (adc == NULL)
{
aerr("ERROR: Failed to get ADC1 interface\n");
return -ENODEV;
}
/* Register the ADC driver at "/dev/adc0" */
ret = adc_register("/dev/adc0", adc);
if (ret < 0)
{
aerr("ERROR: adc_register adc0 failed: %d\n", ret);
return ret;
}
#endif
#ifdef CONFIG_SAMV7_AFEC1
adc = sam_afec_initialize(1, g_chanlist1, ADC1_NCHANNELS);
if (adc == NULL)
{
aerr("ERROR: Failed to get ADC2 interface\n");
return -ENODEV;
}
/* Register the ADC driver at "/dev/adc1" */
ret = adc_register("/dev/adc1", adc);
if (ret < 0)
{
aerr("ERROR: adc_register adc1 failed: %d\n", ret);
return ret;
}
#endif
return OK;
}
#endif /* CONFIG_SAMV7_AFEC */

View file

@ -0,0 +1,105 @@
/****************************************************************************
* boards/arm/samv7/same70-qmtech/src/sam_appinit.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#include "sam_uid.h"
#include "same70-qmtech.h"
#ifdef CONFIG_BOARDCTL
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_app_initialize
*
* Description:
* Perform application specific initialization. This function is never
* called directly from application code, but only indirectly via the
* (non-standard) boardctl() interface using the command BOARDIOC_INIT.
*
* Input Parameters:
* arg - The boardctl() argument is passed to the board_app_initialize()
* implementation without modification. The argument has no
* meaning to NuttX; the meaning of the argument is a contract
* between the board-specific initialization logic and the
* matching application logic. The value could be such things as a
* mode enumeration value, a set of DIP switch switch settings, a
* pointer to configuration data read from a file or serial FLASH,
* or whatever you would like to do with it. Every implementation
* should accept zero/NULL as a default configuration.
*
* Returned Value:
* Zero (OK) is returned on success; a negated errno value is returned on
* any failure to indicate the nature of the failure.
*
****************************************************************************/
int board_app_initialize(uintptr_t arg)
{
#ifndef CONFIG_BOARD_LATE_INITIALIZE
/* Perform board initialization */
return sam_bringup();
#else
return OK;
#endif
}
#ifdef CONFIG_BOARDCTL_IOCTL
int board_ioctl(unsigned int cmd, uintptr_t arg)
{
switch (cmd)
{
default:
return -ENOTTY; /* Standard return for command not supported */
break;
}
return OK;
}
#endif
#if defined(CONFIG_BOARDCTL_UNIQUEID)
int board_uniqueid(uint8_t *uniqueid)
{
if (uniqueid == NULL)
{
return -EINVAL;
}
sam_get_uniqueid(uniqueid);
return OK;
}
#endif
#endif /* CONFIG_BOARDCTL */

View file

@ -0,0 +1,105 @@
/****************************************************************************
* boards/arm/samv7/same70-qmtech/src/sam_autoleds.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/* LEDs
*
* A single LED is available driven by PC8.
*
* These LEDs are not used by the board port unless CONFIG_ARCH_LEDS is
* defined. In that case, the usage by the board port is defined in
* include/board.h and src/sam_autoleds.c. The LEDs are used to encode
* OS-related events as follows:
*
* ------------------- ----------------------- ------
* SYMBOL Meaning LED
* ------------------- ----------------------- ------
* LED_STARTED NuttX has been started OFF
* LED_HEAPALLOCATE Heap has been allocated OFF
* LED_IRQSENABLED Interrupts enabled OFF
* LED_STACKCREATED Idle stack created ON
* LED_INIRQ In an interrupt N/C
* LED_SIGNAL In a signal handler N/C
* LED_ASSERTION An assertion failed N/C
* LED_PANIC The system has crashed FLASH
*
* Thus is LED is statically on, NuttX has successfully booted and is,
* apparently, running normally. If LED is flashing at approximately
* 2Hz, then a fatal error has been detected and the system has halted.
*/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <assert.h>
#include <debug.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#include "sam_gpio.h"
#include "same70-qmtech.h"
#ifdef CONFIG_ARCH_LEDS
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_autoled_initialize
****************************************************************************/
void board_autoled_initialize(void)
{
/* Configure LED PIOs for output */
sam_configgpio(GPIO_LED0);
}
/****************************************************************************
* Name: board_autoled_on
****************************************************************************/
void board_autoled_on(int led)
{
if (led == 1 || led == 3)
{
sam_gpiowrite(GPIO_LED0, false); /* Low illuminates */
}
}
/****************************************************************************
* Name: board_autoled_off
****************************************************************************/
void board_autoled_off(int led)
{
if (led == 3)
{
sam_gpiowrite(GPIO_LED0, true); /* High extinguishes */
}
}
#endif /* CONFIG_ARCH_LEDS */

View file

@ -0,0 +1,341 @@
/****************************************************************************
* boards/arm/samv7/same70-qmtech/src/sam_automount.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#if defined(CONFIG_FS_AUTOMOUNTER_DEBUG) && !defined(CONFIG_DEBUG_FS)
# define CONFIG_DEBUG_FS 1
#endif
#include <assert.h>
#include <debug.h>
#include <nuttx/irq.h>
#include <nuttx/clock.h>
#include <nuttx/fs/automount.h>
#include "same70-qmtech.h"
#ifdef HAVE_AUTOMOUNTER
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifndef NULL
# define NULL (FAR void *)0
#endif
#ifndef OK
# define OK 0
#endif
/****************************************************************************
* Private Types
****************************************************************************/
/* This structure represents the changeable state of the automounter */
struct sam_automount_state_s
{
volatile automount_handler_t handler; /* Upper half handler */
FAR void *arg; /* Handler argument */
bool enable; /* Fake interrupt enable */
bool pending; /* Set if there an event while disabled */
};
/* This structure represents the static configuration of an automounter */
struct sam_automount_config_s
{
/* This must be first thing in structure so that we can simply cast from
* struct automount_lower_s to struct sam_automount_config_s
*/
struct automount_lower_s lower; /* Publicly visible part */
uint8_t hsmci; /* HSMCI0_SLOTNO or HSMCI1_SLOTNO */
FAR struct sam_automount_state_s *state; /* Changeable state */
};
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
static int sam_attach(FAR const struct automount_lower_s *lower,
automount_handler_t isr, FAR void *arg);
static void sam_enable(FAR const struct automount_lower_s *lower,
bool enable);
static bool sam_inserted(FAR const struct automount_lower_s *lower);
/****************************************************************************
* Private Data
****************************************************************************/
#ifdef CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT
static struct sam_automount_state_s g_hsmci0state;
static const struct sam_automount_config_s g_hsmci0config =
{
.lower =
{
.fstype = CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_FSTYPE,
.blockdev = CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_BLKDEV,
.mountpoint = CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_MOUNTPOINT,
.ddelay = MSEC2TICK(CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_DDELAY),
.udelay = MSEC2TICK(CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_UDELAY),
.attach = sam_attach,
.enable = sam_enable,
.inserted = sam_inserted
},
.hsmci = HSMCI0_SLOTNO,
.state = &g_hsmci0state
};
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: sam_attach
*
* Description:
* Attach a new HSMCI event handler
*
* Input Parameters:
* lower - An instance of the auto-mounter lower half state structure
* isr - The new event handler to be attach
* arg - Client data to be provided when the event handler is invoked.
*
* Returned Value:
* Always returns OK
*
****************************************************************************/
static int sam_attach(FAR const struct automount_lower_s *lower,
automount_handler_t isr, FAR void *arg)
{
FAR const struct sam_automount_config_s *config;
FAR struct sam_automount_state_s *state;
/* Recover references to our structure */
config = (FAR struct sam_automount_config_s *)lower;
DEBUGASSERT(config && config->state);
state = config->state;
/* Save the new handler info (clearing the handler first to eliminate race
* conditions).
*/
state->handler = NULL;
state->pending = false;
state->arg = arg;
state->handler = isr;
return OK;
}
/****************************************************************************
* Name: sam_enable
*
* Description:
* Enable card insertion/removal event detection
*
* Input Parameters:
* lower - An instance of the auto-mounter lower half state structure
* enable - True: enable event detection; False: disable
*
* Returned Value:
* None
*
****************************************************************************/
static void sam_enable(FAR const struct automount_lower_s *lower,
bool enable)
{
FAR const struct sam_automount_config_s *config;
FAR struct sam_automount_state_s *state;
irqstate_t flags;
/* Recover references to our structure */
config = (FAR struct sam_automount_config_s *)lower;
DEBUGASSERT(config && config->state);
state = config->state;
/* Save the fake enable setting */
flags = enter_critical_section();
state->enable = enable;
/* Did an interrupt occur while interrupts were disabled? */
if (enable && state->pending)
{
/* Yes.. perform the fake interrupt if the interrutp is attached */
if (state->handler)
{
bool inserted = sam_cardinserted(config->hsmci);
(void)state->handler(&config->lower, state->arg, inserted);
}
state->pending = false;
}
leave_critical_section(flags);
}
/****************************************************************************
* Name: sam_inserted
*
* Description:
* Check if a card is inserted into the slot.
*
* Input Parameters:
* lower - An instance of the auto-mounter lower half state structure
*
* Returned Value:
* True if the card is inserted; False otherwise
*
****************************************************************************/
static bool sam_inserted(FAR const struct automount_lower_s *lower)
{
FAR const struct sam_automount_config_s *config;
config = (FAR struct sam_automount_config_s *)lower;
DEBUGASSERT(config && config->state);
return sam_cardinserted(config->hsmci);
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: sam_automount_initialize
*
* Description:
* Configure auto-mounters for each enable and so configured HSMCI
*
* Input Parameters:
* None
*
* Returned Value:
* None
*
****************************************************************************/
void sam_automount_initialize(void)
{
FAR void *handle;
finfo("Initializing automounter(s)\n");
#ifdef CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT
/* Initialize the HSMCI0 auto-mounter */
handle = automount_initialize(&g_hsmci0config.lower);
if (!handle)
{
ferr("ERROR: Failed to initialize auto-mounter for HSMCI0\n");
}
#endif
}
/****************************************************************************
* Name: sam_automount_event
*
* Description:
* The HSMCI card detection logic has detected an insertion or removal
* event.
* It has already scheduled the MMC/SD block driver operations.
* Now we need to schedule the auto-mount event which will occur with a
* substantial delay to make sure that everything has settle down.
*
* Input Parameters:
* slotno - Identifies the HSMCI0 slot: HSMCI0_SLOTNO or HSMCI1_SLOTNO.
* There is a terminology problem here: Each HSMCI supports two slots,
* slot A and slot B.
* Only slot A is used. So this is not a really a slot, but an HSCMI
* peripheral number.
* inserted - True if the card is inserted in the slot. False otherwise.
*
* Returned Value:
* None
*
* Assumptions:
* Interrupts are disabled.
*
****************************************************************************/
void sam_automount_event(int slotno, bool inserted)
{
FAR const struct sam_automount_config_s *config;
FAR struct sam_automount_state_s *state;
#ifdef CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT
/* Is this a change in the HSMCI0 insertion state? */
if (slotno == HSMCI0_SLOTNO)
{
/* Yes.. Select the HSMCI0 automounter */
config = &g_hsmci0config;
state = &g_hsmci0state;
}
else
#endif
{
ferr("ERROR: Unsupported HSCMI%d\n", slotno);
return;
}
/* Is the auto-mounter interrupt attached? */
if (state->handler)
{
/* Yes.. Have we been asked to hold off interrupts? */
if (!state->enable)
{
/* Yes.. just remember that there is a pending interrupt. We will
* deliver the interrupt when interrupts are "re-enabled."
*/
state->pending = true;
}
else
{
/* No.. forward the event to the handler */
(void)state->handler(&config->lower, state->arg, inserted);
}
}
}
#endif /* HAVE_AUTOMOUNTER */

View file

@ -0,0 +1,122 @@
/****************************************************************************
* boards/arm/samv7/same70-qmtech/src/sam_boot.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <assert.h>
#include <debug.h>
#include <nuttx/board.h>
#include <nuttx/clock.h>
#include <arch/board/board.h>
#include "arm_arch.h"
#include "sam_start.h"
#include "sam_pck.h"
#include "same70-qmtech.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: sam_boardinitialize
*
* Description:
* All SAMV7 architectures must provide the following entry point. This
* entry point is called early in the initialization -- after clocking and
* memory have been configured but before caches have been enabled and
* before any devices have been initialized.
*
****************************************************************************/
void sam_boardinitialize(void)
{
#ifdef CONFIG_SCHED_TICKLESS
uint32_t frequency;
uint32_t actual;
/* If Tickless mode is selected then enabled PCK6 as a possible clock
* source for the timer/counters. The ideal frequency could be:
*
* frequency = 1,000,000 / CONFIG_USEC_PER_TICK
*
* The main crystal is selected as the frequency source. The maximum
* prescaler value is 256 so the minimum frequency is 46,875 Hz which
* corresponds to a period of 21.3 microseconds. A value of
* CONFIG_USEC_PER_TICK=20, or 50KHz, would give an exact solution with
* a divider of 240.
*/
frequency = USEC_PER_SEC / CONFIG_USEC_PER_TICK;
DEBUGASSERT(frequency >= (BOARD_MAINOSC_FREQUENCY / 256));
actual = sam_pck_configure(PCK6, PCKSRC_MAINCK, frequency);
/* We expect to achieve this frequency exactly */
DEBUGASSERT(actual == frequency);
UNUSED(actual);
/* Enable PCK6 */
sam_pck_enable(PCK6, true);
#endif
#ifdef CONFIG_SAMV7_SPI
/* Configure SPI chip selects if SPI has been enabled */
sam_spidev_initialize();
#endif
/* Configure on-board LEDs if LED support has been selected. */
#ifdef CONFIG_ARCH_LEDS
board_autoled_initialize();
#endif
}
/****************************************************************************
* Name: board_late_initialize
*
* Description:
* If CONFIG_BOARD_LATE_INITIALIZE is selected, then an additional
* initialization call will be performed in the boot-up sequence to a
* function called board_late_initialize(). board_late_initialize() will be
* called immediately after up_intitialize() is called and just before the
* initial application is started. This additional initialization phase
* may be used, for example, to initialize board-specific device drivers.
*
****************************************************************************/
#ifdef CONFIG_BOARD_LATE_INITIALIZE
void board_late_initialize(void)
{
/* Perform board initialization */
sam_bringup();
}
#endif /* CONFIG_BOARD_LATE_INITIALIZE */

View file

@ -0,0 +1,186 @@
/****************************************************************************
* boards/arm/samv7/same70-qmtech/src/sam_boot_image.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <debug.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/boardctl.h>
#include <nuttx/irq.h>
#include <nuttx/cache.h>
#include "nvic.h"
#include "arm_arch.h"
#include "barriers.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/* This structure represents the first two entries on NVIC vector table */
struct arm_vector_table
{
uint32_t spr; /* Stack pointer on reset */
uint32_t reset; /* Pointer to reset exception handler */
};
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
static void cleanup_arm_nvic(void);
#ifdef CONFIG_ARMV7M_SYSTICK
static void systick_disable(void);
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: cleanup_arm_nvic
*
* Description:
* Acknowledge and disable all interrupts in NVIC
*
* Input Parameters:
* None
*
* Returned Value:
* None
*
****************************************************************************/
static void cleanup_arm_nvic(void)
{
int i;
/* Allow any pending interrupts to be recognized */
ARM_ISB();
cpsid();
/* Disable all interrupts */
for (i = 0; i < SAM_IRQ_NIRQS; i += 32)
{
putreg32(0xffffffff, NVIC_IRQ_CLEAR(i));
}
/* Clear all pending interrupts */
for (i = 0; i < SAM_IRQ_NIRQS; i += 32)
{
putreg32(0xffffffff, NVIC_IRQ_CLRPEND(i));
}
}
#ifdef CONFIG_ARMV7M_SYSTICK
/****************************************************************************
* Name: systick_disable
*
* Description:
* Disable the SysTick system timer
*
* Input Parameters:
* None
*
* Returned Value:
* None
*
****************************************************************************/
static void systick_disable(void)
{
putreg32(0, NVIC_SYSTICK_CTRL);
putreg32(NVIC_SYSTICK_RELOAD_MASK, NVIC_SYSTICK_RELOAD);
putreg32(0, NVIC_SYSTICK_CURRENT);
}
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_boot_image
*
* Description:
* This entry point is called by bootloader to jump to application image.
*
****************************************************************************/
int board_boot_image(FAR const char *path, uint32_t hdr_size)
{
static struct arm_vector_table vt;
int fd;
ssize_t bytes;
fd = open(path, O_RDONLY | O_CLOEXEC);
if (fd < 0)
{
syslog(LOG_ERR, "Failed to open %s with: %d", path, fd);
return fd;
}
bytes = pread(fd, &vt, sizeof(vt), hdr_size);
if (bytes != sizeof(vt))
{
syslog(LOG_ERR, "Failed to read ARM vector table: %d", bytes);
return bytes < 0 ? bytes : -1;
}
#ifdef CONFIG_ARMV7M_SYSTICK
systick_disable();
#endif
cleanup_arm_nvic();
#ifdef CONFIG_ARMV7M_DCACHE
up_disable_dcache();
#endif
#ifdef CONFIG_ARMV7M_ICACHE
up_disable_icache();
#endif
#ifdef CONFIG_ARM_MPU
mpu_control(false, false, false);
#endif
/* Set main and process stack pointers */
__asm__ __volatile__("\tmsr msp, %0\n" : : "r" (vt.spr));
setcontrol(0x00);
ARM_ISB();
((void (*)(void))vt.reset)();
return 0;
}

View file

@ -0,0 +1,198 @@
/****************************************************************************
* boards/arm/samv7/same70-qmtech/src/sam_bringup.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/mount.h>
#include <stdbool.h>
#include <stdio.h>
#include <syslog.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/drivers/drivers.h>
#include <nuttx/drivers/ramdisk.h>
#include <nuttx/fs/fs.h>
#include <nuttx/fs/nxffs.h>
#include <nuttx/i2c/i2c_master.h>
#include "sam_twihs.h"
#include "same70-qmtech.h"
#ifdef HAVE_ROMFS
# include <arch/board/boot_romfsimg.h>
#endif
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define NSECTORS(n) \
(((n)+CONFIG_SAME70QMTECH_ROMFS_ROMDISK_SECTSIZE-1) / \
CONFIG_SAME70QMTECH_ROMFS_ROMDISK_SECTSIZE)
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: sam_bringup
*
* Description:
* Bring up board features
*
****************************************************************************/
int sam_bringup(void)
{
int ret;
#ifdef CONFIG_FS_PROCFS
/* Mount the procfs file system */
ret = nx_mount(NULL, SAME70_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: Failed to mount procfs at %s: %d\n",
SAME70_PROCFS_MOUNTPOINT, ret);
}
#endif
#ifdef HAVE_HSMCI
/* Initialize the HSMCI0 driver */
ret = sam_hsmci_initialize(HSMCI0_SLOTNO, HSMCI0_MINOR);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: sam_hsmci_initialize(%d,%d) failed: %d\n",
HSMCI0_SLOTNO, HSMCI0_MINOR, ret);
}
#ifdef CONFIG_SAME70QMTECH_HSMCI0_MOUNT
else
{
/* REVISIT: A delay seems to be required here or the mount will fail */
/* Mount the volume on HSMCI0 */
ret = nx_mount(CONFIG_SAME70QMTECH_HSMCI0_MOUNT_BLKDEV,
CONFIG_SAME70QMTECH_HSMCI0_MOUNT_MOUNTPOINT,
CONFIG_SAME70QMTECH_HSMCI0_MOUNT_FSTYPE,
0, NULL);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: Failed to mount %s: %d\n",
CONFIG_SAME70QMTECH_HSMCI0_MOUNT_MOUNTPOINT, ret);
}
}
#endif /* CONFIG_SAME70QMTECH_HSMCI0_MOUNT */
#endif /* HAVE_HSMCI */
#ifdef HAVE_AUTOMOUNTER
/* Initialize the auto-mounter */
sam_automount_initialize();
#endif
#ifdef HAVE_ROMFS
/* Create a ROM disk for the /etc filesystem */
ret = romdisk_register(CONFIG_SAME70QMTECH_ROMFS_ROMDISK_MINOR,
romfs_img, NSECTORS(romfs_img_len),
CONFIG_SAME70QMTECH_ROMFS_ROMDISK_SECTSIZE);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: romdisk_register failed: %d\n", -ret);
}
else
{
/* Mount the file system */
ret = nx_mount(CONFIG_SAME70QMTECH_ROMFS_ROMDISK_DEVNAME,
CONFIG_SAME70QMTECH_ROMFS_MOUNT_MOUNTPOINT,
"romfs", MS_RDONLY, NULL);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: nx_mount(%s,%s,romfs) failed: %d\n",
CONFIG_SAME70QMTECH_ROMFS_ROMDISK_DEVNAME,
CONFIG_SAME70QMTECH_ROMFS_MOUNT_MOUNTPOINT, ret);
}
}
#endif
#ifdef HAVE_PROGMEM_CHARDEV
/* Initialize the SAME70 FLASH programming memory library */
ret = sam_progmem_init();
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: Failed to initialize progmem: %d\n", ret);
return ret;
}
#endif
#ifdef CONFIG_SAMV7_MCAN
/* Initialize CAN and register the CAN driver. */
ret = sam_can_setup();
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: sam_can_setup failed: %d\n", ret);
}
#endif
#ifdef CONFIG_SAMV7_AFEC
/* Initialize AFEC and register the ADC driver. */
ret = sam_afec_setup();
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: sam_afec_initialize failed: %d\n", ret);
}
#endif
#if defined(CONFIG_SAMV7_DAC0) || defined(CONFIG_SAMV7_DAC1)
ret = sam_dacdev_initialize();
if (ret < 0)
{
syslog(LOG_ERR,
"ERROR: Initialization of the DAC module failed: %d\n", ret);
}
#endif
/* If we got here then perhaps not all initialization was successful, but
* at least enough succeeded to bring-up NSH with perhaps reduced
* capabilities.
*/
UNUSED(ret);
return OK;
}

View file

@ -0,0 +1,172 @@
/****************************************************************************
* boards/arm/samv7/same70-qmtech/src/sam_buttons.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
#include <nuttx/irq.h>
#include <nuttx/irq.h>
#include <arch/board/board.h>
#include "arm_arch.h"
#include "sam_gpio.h"
#include "hardware/sam_matrix.h"
#include "same70-qmtech.h"
#ifdef CONFIG_ARCH_BUTTONS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
# define HAVE_IRQBUTTONS 1
# ifndef CONFIG_SAMV7_GPIOA_IRQ
# undef HAVE_IRQBUTTONS
# endif
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: board_button_irqx
*
* Description:
* This function implements the core of the board_button_irq() logic.
*
****************************************************************************/
#ifdef HAVE_IRQBUTTONS
static int board_button_irqx(gpio_pinset_t pinset, int irq,
xcpt_t irqhandler, void *arg)
{
irqstate_t flags;
/* Disable interrupts until we are done. This guarantees that the
* following operations are atomic.
*/
flags = enter_critical_section();
/* Are we attaching or detaching? */
if (irqhandler != NULL)
{
/* Configure the interrupt */
sam_gpioirq(pinset);
irq_attach(irq, irqhandler, arg);
sam_gpioirqenable(irq);
}
else
{
/* Detach and disable the interrupt */
irq_detach(irq);
sam_gpioirqdisable(irq);
}
leave_critical_section(flags);
return OK;
}
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_button_initialize
*
* Description:
* board_button_initialize() must be called to initialize button resources.
* After that, board_buttons() may be called to collect the current state
* of all buttons or board_button_irq() may be called to register button
* interrupt handlers.
*
****************************************************************************/
uint32_t board_button_initialize(void)
{
/* Configure button PIOs */
sam_configgpio(GPIO_SW0);
return NUM_BUTTONS;
}
/****************************************************************************
* Name: board_buttons
*
* Description:
* After board_button_initialize() has been called, board_buttons() may be
* called to collect the state of all buttons. board_buttons() returns an
* 32-bit bit set with each bit associated with a button. See the BUTTON*
* definitions above for the meaning of each bit in the returned value.
*
****************************************************************************/
uint32_t board_buttons(void)
{
return sam_gpioread(GPIO_SW0) ? 0 : BUTTON_SW0_BIT;
}
/****************************************************************************
* Name: board_button_irq
*
* Description:
* This function may be called to register an interrupt handler that will
* be called when a button is depressed or released. The ID value is one
* of the BUTTON* definitions provided above.
*
* Configuration Notes:
* Configuration CONFIG_AVR32_GPIOIRQ must be selected to enable the
* overall GPIO IRQ feature and CONFIG_AVR32_GPIOIRQSETA and/or
* CONFIG_AVR32_GPIOIRQSETB must be enabled to select GPIOs to support
* interrupts on. For button support, bits 2 and 3 must be set in
* CONFIG_AVR32_GPIOIRQSETB (PB2 and PB3).
*
****************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
#ifdef HAVE_IRQBUTTONS
if (id == BUTTON_SW0)
{
return board_button_irqx(GPIO_SW0, IRQ_SW0, irqhandler, arg);
}
#endif
return -EINVAL;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View file

@ -0,0 +1,110 @@
/****************************************************************************
* boards/arm/samv7/same70-qmtech/src/sam_dac.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <debug.h>
#include <errno.h>
#include <arch/board/board.h>
#include "arm_arch.h"
#include "chip.h"
#include "sam_dac.h"
#include "same70-qmtech.h"
#if defined(CONFIG_SAMV7_DAC0) || defined(CONFIG_SAMV7_DAC1)
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: sam_dacdev_initialize
*
* Description:
* Called to configure DAC peripheral module and register DAC device driver
****************************************************************************/
int sam_dacdev_initialize(void)
{
static bool initialized = false;
struct dac_dev_s *dac;
int ret;
/* Check if we have already initialized */
if (!initialized)
{
#ifdef CONFIG_SAMV7_DAC0
/* Get an instance of the DAC0 interface */
dac = sam_dac_initialize(0);
if (dac == NULL)
{
aerr("ERROR: Failed to get DAC0 interface\n");
return -ENODEV;
}
/* Register the DAC driver at "/dev/dac0" */
ret = dac_register("/dev/dac0", dac);
if (ret < 0)
{
aerr("ERROR: dac_register failed: %d\n", ret);
return ret;
}
#endif
#ifdef CONFIG_SAMV7_DAC1
/* Get an instance of the DAC1 interface */
dac = sam_dac_initialize(1);
if (dac == NULL)
{
aerr("ERROR: Failed to get DAC1 interface\n");
return -ENODEV;
}
/* Register the DAC driver at "/dev/dac1" */
ret = dac_register("/dev/dac1", dac);
if (ret < 0)
{
aerr("ERROR: dac_register failed: %d\n", ret);
return ret;
}
#endif
/* Now we are initialized */
initialized = true;
}
return OK;
}
#endif /* CONFIG_SAMV7_DAC0 || CONFIG_SAMV7_DAC1 */

View file

@ -0,0 +1,307 @@
/****************************************************************************
* boards/arm/samv7/same70-qmtech/src/sam_hsmci.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/* The SAM E70 Xplained Ultraas one standard SD card connector that is
* connected to the High Speed Multimedia Card Interface (HSMCI) of the SAM
* E70. SD card connector:
*
* ------ ----------------- ---------------------
* SAME70 SAME70 Shared functionality
* Pin Function
* ------ ----------------- ---------------------
* PA30 MCDA0 (DAT0)
* PA31 MCDA1 (DAT1)
* PA26 MCDA2 (DAT2)
* PA27 MCDA3 (DAT3) Camera
* PA25 MCCK (CLK) Shield
* PA28 MCCDA (CMD)
* PD17 Card Detect (C/D) Shield
* ------ ----------------- ---------------------
*/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdbool.h>
#include <stdio.h>
#include <debug.h>
#include <errno.h>
#include <nuttx/sdio.h>
#include <nuttx/mmcsd.h>
#include "sam_gpio.h"
#include "sam_hsmci.h"
#include "same70-qmtech.h"
#ifdef HAVE_HSMCI
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/* This structure holds static information unique to one HSMCI peripheral */
struct sam_hsmci_state_s
{
struct sdio_dev_s *hsmci; /* R/W device handle */
gpio_pinset_t cdcfg; /* Card detect PIO pin configuration */
gpio_pinset_t pwrcfg; /* Power PIO pin configuration */
uint8_t irq; /* Interrupt number (same as pid) */
uint8_t slotno; /* Slot number */
bool cd; /* TRUE: card is inserted */
xcpt_t handler; /* Interrupt handler */
};
/****************************************************************************
* Private Data
****************************************************************************/
/* HSCMI device state */
#ifdef CONFIG_SAMV7_HSMCI0
static int sam_hsmci0_cardetect(int irq, void *regs, FAR void *arg);
static struct sam_hsmci_state_s g_hsmci0 =
{
.cdcfg = GPIO_MCI0_CD,
.irq = IRQ_MCI0_CD,
.slotno = 0,
.handler = sam_hsmci0_cardetect,
};
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: sam_cardinserted_internal
*
* Description:
* Check if a card is inserted into the selected HSMCI slot
*
****************************************************************************/
bool sam_cardinserted_internal(struct sam_hsmci_state_s *state)
{
bool inserted;
/* Get the state of the PIO pin */
inserted = sam_gpioread(state->cdcfg);
finfo("Slot %d inserted: %s\n", state->slotno, inserted ? "NO" : "YES");
return !inserted;
}
/****************************************************************************
* Name: sam_hsmci_cardetect, sam_hsmci0_cardetect, and sam_hsmci1_cardetect
*
* Description:
* Card detect interrupt handlers
*
****************************************************************************/
static int sam_hsmci_cardetect(struct sam_hsmci_state_s *state)
{
/* Get the current card insertion state */
bool cd = sam_cardinserted_internal(state);
/* Has the card detect state changed? */
if (cd != state->cd)
{
/* Yes... remember that new state and inform the HSMCI driver */
state->cd = cd;
/* Report the new state to the SDIO driver */
sdio_mediachange(state->hsmci, cd);
}
return OK;
}
#ifdef CONFIG_SAMV7_HSMCI0
static int sam_hsmci0_cardetect(int irq, void *regs, FAR void *arg)
{
int ret;
/* Handle the card detect interrupt. The interrupt level logic will
* kick of the driver-level operations to initialize the MMC/SD block
* device.
*/
ret = sam_hsmci_cardetect(&g_hsmci0);
#ifdef CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT
/* Let the automounter know about the insertion event */
sam_automount_event(HSMCI0_SLOTNO, sam_cardinserted(HSMCI0_SLOTNO));
#endif
return ret;
}
#endif
/****************************************************************************
* Name: sam_hsmci_state
*
* Description:
* Initialize HSMCI PIOs.
*
****************************************************************************/
static inline struct sam_hsmci_state_s *sam_hsmci_state(int slotno)
{
struct sam_hsmci_state_s *state = NULL;
#ifdef CONFIG_SAMV7_HSMCI0
state = &g_hsmci0;
#endif
return state;
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: sam_hsmci_initialize
*
* Description:
* Perform architecture specific initialization
*
****************************************************************************/
int sam_hsmci_initialize(int slotno, int minor)
{
struct sam_hsmci_state_s *state;
int ret;
/* Get the static HSMI description */
state = sam_hsmci_state(slotno);
if (!state)
{
ferr("ERROR: No state for slotno %d\n", slotno);
return -EINVAL;
}
/* Initialize card-detect, write-protect, and power enable PIOs */
sam_configgpio(state->cdcfg);
sam_dumpgpio(state->cdcfg, "HSMCI Card Detect");
if (state->pwrcfg != 0)
{
sam_configgpio(state->pwrcfg);
sam_dumpgpio(state->pwrcfg, "HSMCI Power");
}
/* Mount the SDIO-based MMC/SD block driver */
/* First, get an instance of the SDIO interface */
state->hsmci = sdio_initialize(slotno);
if (!state->hsmci)
{
ferr("ERROR: Failed to initialize SDIO slot %d\n", slotno);
return -ENODEV;
}
/* Now bind the SDIO interface to the MMC/SD driver */
ret = mmcsd_slotinitialize(minor, state->hsmci);
if (ret != OK)
{
ferr("ERROR: Failed to bind SDIO to the MMC/SD driver: %d\n", ret);
return ret;
}
/* Configure card detect interrupts */
sam_gpioirq(state->cdcfg);
irq_attach(state->irq, state->handler, NULL);
/* Then inform the HSMCI driver if there is or is not a card in the slot. */
state->cd = sam_cardinserted_internal(state);
sdio_mediachange(state->hsmci, state->cd);
/* Enable card detect interrupts */
sam_gpioirqenable(state->irq);
return OK;
}
/****************************************************************************
* Name: sam_cardinserted
*
* Description:
* Check if a card is inserted into the selected HSMCI slot
*
****************************************************************************/
bool sam_cardinserted(int slotno)
{
struct sam_hsmci_state_s *state;
/* Get the HSMI description */
state = sam_hsmci_state(slotno);
if (!state)
{
ferr("ERROR: No state for slotno %d\n", slotno);
return false;
}
/* Return the state of the PIO pin */
return sam_cardinserted_internal(state);
}
/****************************************************************************
* Name: sam_writeprotected
*
* Description:
* Check if a card is inserted into the selected HSMCI slot
*
****************************************************************************/
bool sam_writeprotected(int slotno)
{
/* There are no write protect pins */
return false;
}
#endif /* HAVE_HSMCI */

View file

@ -0,0 +1,98 @@
/****************************************************************************
* boards/arm/samv7/same70-qmtech/src/sam_mcan.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdbool.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/can/can.h>
#include <arch/board/board.h>
#include "sam_mcan.h"
#include "same70-qmtech.h"
#ifdef CONFIG_SAMV7_MCAN
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
#if defined(CONFIG_SAMV7_MCAN0) && defined(CONFIG_SAMV7_MCAN1)
# warning "Both MCAN0 and MCAN1 are enabled. Assuming only CAN1."
# undef CONFIG_SAMV7_MCAN0
#endif
#ifdef CONFIG_SAMV7_MCAN0
# define CAN_PORT 0
#else
# define CAN_PORT 1
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: sam_can_setup
*
* Description:
* Initialize CAN and register the CAN device
*
****************************************************************************/
int sam_can_setup(void)
{
#if defined(CONFIG_SAMV7_MCAN0) || defined(CONFIG_SAMV7_MCAN1)
struct can_dev_s *can;
int ret;
/* Call stm32_caninitialize() to get an instance of the CAN interface */
can = sam_mcan_initialize(CAN_PORT);
if (can == NULL)
{
canerr("ERROR: Failed to get CAN interface\n");
return -ENODEV;
}
/* Register the CAN driver at "/dev/can0" */
ret = can_register("/dev/can0", can);
if (ret < 0)
{
canerr("ERROR: can_register failed: %d\n", ret);
return ret;
}
return OK;
#else
return -ENODEV;
#endif
}
#endif /* CONFIG_SAMV7_MCAN */

View file

@ -0,0 +1,268 @@
/****************************************************************************
* boards/arm/samv7/same70-qmtech/src/sam_progmem.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/mount.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/kmalloc.h>
#include <nuttx/mtd/mtd.h>
#ifdef CONFIG_BCH
#include <nuttx/drivers/drivers.h>
#endif
#include "sam_progmem.h"
#include "same70-qmtech.h"
#ifdef HAVE_PROGMEM_CHARDEV
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
/****************************************************************************
* Private Types
****************************************************************************/
#if defined(CONFIG_SAME70QMTECH_PROGMEM_OTA_PARTITION)
struct ota_partition_s
{
uint32_t offset; /* Partition offset from the beginning of MTD */
uint32_t size; /* Partition size in bytes */
const char *devpath; /* Partition device path */
};
#endif
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
#if defined(CONFIG_SAME70QMTECH_PROGMEM_OTA_PARTITION)
static struct mtd_dev_s *sam_progmem_alloc_mtdpart(uint32_t mtd_offset,
uint32_t mtd_size);
static int init_ota_partitions(void);
#endif
/****************************************************************************
* Private Data
****************************************************************************/
static FAR struct mtd_dev_s *g_samv7_progmem_mtd;
#if defined(CONFIG_SAME70QMTECH_PROGMEM_OTA_PARTITION)
static const struct ota_partition_s g_ota_partition_table[] =
{
{
.offset = CONFIG_SAME70QMTECH_OTA_PRIMARY_SLOT_OFFSET,
.size = CONFIG_SAME70QMTECH_OTA_SLOT_SIZE,
.devpath = CONFIG_SAME70QMTECH_OTA_PRIMARY_SLOT_DEVPATH
},
{
.offset = CONFIG_SAME70QMTECH_OTA_SECONDARY_SLOT_OFFSET,
.size = CONFIG_SAME70QMTECH_OTA_SLOT_SIZE,
.devpath = CONFIG_SAME70QMTECH_OTA_SECONDARY_SLOT_DEVPATH
},
{
.offset = CONFIG_SAME70QMTECH_OTA_SCRATCH_OFFSET,
.size = CONFIG_SAME70QMTECH_OTA_SCRATCH_SIZE,
.devpath = CONFIG_SAME70QMTECH_OTA_SCRATCH_DEVPATH
}
};
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
#if defined(CONFIG_SAME70QMTECH_PROGMEM_OTA_PARTITION)
/****************************************************************************
* Name: sam_progmem_alloc_mtdpart
*
* Description:
* Allocate an MTD partition from FLASH.
*
* Input Parameters:
* mtd_offset - MTD Partition offset from the base address in FLASH.
* mtd_size - Size for the MTD partition.
*
* Returned Value:
* MTD partition data pointer on success, NULL on failure.
*
****************************************************************************/
static struct mtd_dev_s *sam_progmem_alloc_mtdpart(uint32_t mtd_offset,
uint32_t mtd_size)
{
uint32_t blocks;
uint32_t startblock;
ASSERT((mtd_offset + mtd_size) <= up_progmem_neraseblocks() *
up_progmem_pagesize(0));
ASSERT((mtd_offset % up_progmem_pagesize(0)) == 0);
ASSERT((mtd_size % up_progmem_pagesize(0)) == 0);
finfo("\tMTD offset = 0x%"PRIx32"\n", mtd_offset);
finfo("\tMTD size = 0x%"PRIx32"\n", mtd_size);
startblock = up_progmem_getpage(mtd_offset);
if (startblock < 0)
{
return NULL;
}
blocks = mtd_size / up_progmem_pagesize(0);
return mtd_partition(g_samv7_progmem_mtd, startblock, blocks);
}
/****************************************************************************
* Name: init_ota_partitions
*
* Description:
* Initialize partitions that are dedicated to firmware OTA update.
*
* Input Parameters:
* None.
*
* Returned Value:
* Zero on success; a negated errno value on failure.
*
****************************************************************************/
static int init_ota_partitions(void)
{
FAR struct mtd_dev_s *mtd;
#ifdef CONFIG_BCH
char blockdev[18];
#endif
int ret = OK;
for (int i = 0; i < ARRAYSIZE(g_ota_partition_table); ++i)
{
const struct ota_partition_s *part = &g_ota_partition_table[i];
mtd = sam_progmem_alloc_mtdpart(part->offset, part->size);
ret = ftl_initialize(i, mtd);
if (ret < 0)
{
ferr("ERROR: Failed to initialize the FTL layer: %d\n", ret);
return ret;
}
#ifdef CONFIG_BCH
snprintf(blockdev, 18, "/dev/mtdblock%d", i);
ret = bchdev_register(blockdev, part->devpath, false);
if (ret < 0)
{
ferr("ERROR: bchdev_register %s failed: %d\n", part->devpath, ret);
return ret;
}
#endif
}
return ret;
}
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: sam_progmem_init
*
* Description:
* Initialize the FLASH and register the MTD device.
****************************************************************************/
int sam_progmem_init(void)
{
int ret = OK;
/* Initialize the SAME70 FLASH programming memory library */
sam_progmem_initialize();
/* Create an instance of the SAME70 FLASH program memory device driver */
g_samv7_progmem_mtd = progmem_initialize();
if (g_samv7_progmem_mtd == NULL)
{
return -EFAULT;
}
#if defined(CONFIG_SAME70QMTECH_PROGMEM_OTA_PARTITION)
ret = init_ota_partitions();
if (ret < 0)
{
return ret;
}
#else
/* Use the FTL layer to wrap the MTD driver as a block driver */
ret = ftl_initialize(PROGMEM_MTD_MINOR, g_samv7_progmem_mtd);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: Failed to initialize the FTL layer: %d\n",
ret);
return ret;
}
#ifdef CONFIG_BCH
char blockdev[18];
char chardev[12];
/* Use the minor number to create device paths */
snprintf(blockdev, 18, "/dev/mtdblock%d", PROGMEM_MTD_MINOR);
snprintf(chardev, 12, "/dev/mtd%d", PROGMEM_MTD_MINOR);
/* Now create a character device on the block device */
ret = bchdev_register(blockdev, chardev, false);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: bchdev_register %s failed: %d\n",
chardev, ret);
return ret;
}
#endif /* CONFIG_BCH */
#endif
return ret;
}
#endif /* HAVE_PROGMEM_CHARDEV */

View file

@ -0,0 +1,62 @@
/****************************************************************************
* boards/arm/samv7/same70-qmtech/src/sam_reset.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
#ifdef CONFIG_BOARDCTL_RESET
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_reset
*
* Description:
* Reset board. Support for this function is required by board-level
* logic if CONFIG_BOARDCTL_RESET is selected.
*
* Input Parameters:
* status - Status information provided with the reset event. This
* meaning of this status information is board-specific. If not
* used by a board, the value zero may be provided in calls to
* board_reset().
*
* Returned Value:
* If this function returns, then it was not possible to power-off the
* board due to some constraints. The return value int this case is a
* board-specific reason for the failure to shutdown.
*
****************************************************************************/
int board_reset(int status)
{
up_systemreset();
return 0;
}
#endif /* CONFIG_BOARDCTL_RESET */

View file

@ -0,0 +1,177 @@
/****************************************************************************
* boards/arm/samv7/same70-qmtech/src/sam_spi.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <assert.h>
#include <debug.h>
#include <errno.h>
#include <nuttx/spi/spi.h>
#include <arch/board/board.h>
#include "arm_arch.h"
#include "chip.h"
#include "sam_gpio.h"
#include "sam_spi.h"
#include "same70-qmtech.h"
#ifdef CONFIG_SAMV7_SPI
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: sam_spidev_initialize
*
* Description:
* Called to configure SPI chip select PIO pins for the SAME70-QMTECH
* board.
*
****************************************************************************/
void sam_spidev_initialize(void)
{
#ifdef CONFIG_SAMV7_SPI0_MASTER
#endif
#ifdef CONFIG_SAMV7_SPI0_SLAVE
#endif
#ifdef CONFIG_SAMV7_SPI1_MASTER
#endif
#ifdef CONFIG_SAMV7_SPI1_SLAVE
#endif
}
/****************************************************************************
* Name: sam_spi[0|1]select, sam_spi[0|1]status, and sam_spi[0|1]cmddata
*
* Description:
* These external functions must be provided by board-specific logic.
* They include:
*
* o sam_spi[0|1]select is a functions tomanage the board-specific chip
* selects
* o sam_spi[0|1]status and sam_spi[0|1]cmddata: Implementations of the
* status and cmddata methods of the SPI interface defined by struct
* spi_ops_ (see include/nuttx/spi/spi.h).
* All other methods including sam_spibus_initialize()) are provided by
* common SAM3/4 logic.
*
* To use this common SPI logic on your board:
*
* 1. Provide logic in sam_boardinitialize() to configure SPI chip select
* pins.
* 2. Provide sam_spi[0|1]select() and sam_spi[0|1]status() functions in
* your board-specific logic.
* These functions will perform chip selection and status operations
* using PIOs in the way your board is configured.
* 2. If CONFIG_SPI_CMDDATA is defined in the NuttX configuration, provide
* sam_spi[0|1]cmddata() functions in your board-specific logic. This
* function will perform cmd/data selection operations using PIOs in
* the way your board is configured.
* 3. Add a call to sam_spibus_initialize() in your low level application
* initialization logic
* 4. The handle returned by sam_spibus_initialize() may then be used to
* bind the SPI driver to higher level logic (e.g., calling
* mmcsd_spislotinitialize(), for example, will bind the SPI driver to
* the SPI MMC/SD driver).
*
****************************************************************************/
/****************************************************************************
* Name: sam_spi[0|1]select
*
* Description:
* PIO chip select pins may be programmed by the board specific logic in
* one of two different ways. First, the pins may be programmed as SPI
* peripherals. In that case, the pins are completely controlled by the
* SPI driver. This method still needs to be provided, but it may be only
* a stub.
*
* An alternative way to program the PIO chip select pins is as a normal
* PIO output. In that case, the automatic control of the CS pins is
* bypassed and this function must provide control of the chip select.
* NOTE: In this case, the PIO output pin does *not* have to be the
* same as the NPCS pin normal associated with the chip select number.
*
* Input Parameters:
* devid - Identifies the (logical) device
* selected - TRUE:Select the device, FALSE:De-select the device
*
* Returned Value:
* None
*
****************************************************************************/
#ifdef CONFIG_SAMV7_SPI0_MASTER
void sam_spi0select(uint32_t devid, bool selected)
{
spiinfo("devid: %d CS: %s\n", (int)devid,
selected ? "assert" : "de-assert");
}
#endif
#ifdef CONFIG_SAMV7_SPI1_MASTER
void sam_spi1select(uint32_t devid, bool selected)
{
spiinfo("devid: %d CS: %s\n", (int)devid,
selected ? "assert" : "de-assert");
}
#endif
/****************************************************************************
* Name: sam_spi[0|1]status
*
* Description:
* Return status information associated with the SPI device.
*
* Input Parameters:
* devid - Identifies the (logical) device
*
* Returned Value:
* Bit-encoded SPI status (see include/nuttx/spi/spi.h.
*
****************************************************************************/
#ifdef CONFIG_SAMV7_SPI0_MASTER
uint8_t sam_spi0status(FAR struct spi_dev_s *dev, uint32_t devid)
{
return 0;
}
#endif
#ifdef CONFIG_SAMV7_SPI1_MASTER
uint8_t sam_spi1status(FAR struct spi_dev_s *dev, uint32_t devid)
{
return 0;
}
#endif
#endif /* CONFIG_SAMV7_SPI */

View file

@ -0,0 +1,81 @@
/****************************************************************************
* boards/arm/samv7/same70-qmtech/src/sam_userleds.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <debug.h>
#include <arch/board/board.h>
#include "sam_gpio.h"
#include "same70-qmtech.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_userled_initialize
****************************************************************************/
uint32_t board_userled_initialize(void)
{
/* Configure LED PIOs for output */
sam_configgpio(GPIO_LED0);
return BOARD_NLEDS;
}
/****************************************************************************
* Name: board_userled
****************************************************************************/
void board_userled(int led, bool ledon)
{
if (led == BOARD_LED0)
{
sam_gpiowrite(GPIO_LED0, !ledon); /* Low illuminates */
}
}
/****************************************************************************
* Name: board_userled_all
****************************************************************************/
void board_userled_all(uint32_t ledset)
{
/* Low illuminates */
sam_gpiowrite(GPIO_LED0, (ledset & BOARD_LED0_BIT) == 0);
}

View file

@ -0,0 +1,381 @@
/****************************************************************************
* boards/arm/samv7/same70-qmtech/src/same70-qmtech.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __BOARDS_ARM_SAMV7_SAME70_QMTECH_SRC_SAME70_QMTECH_H
#define __BOARDS_ARM_SAMV7_SAME70_QMTECH_SRC_SAME70_QMTECH_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <arch/irq.h>
#include <nuttx/irq.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
#define HAVE_HSMCI 1
#define HAVE_AUTOMOUNTER 1
#define HAVE_PROGMEM_CHARDEV 1
/* HSMCI */
/* Can't support MMC/SD if the card interface is not enabled */
#if !defined(CONFIG_SAMV7_HSMCI0)
# undef HAVE_HSMCI
#endif
/* Can't support MMC/SD features if mountpoints are disabled */
#if defined(HAVE_HSMCI) && defined(CONFIG_DISABLE_MOUNTPOINT)
# warning Mountpoints disabled. No MMC/SD support
# undef HAVE_HSMCI
#endif
/* We need PIO interrupts on GPIOD to support card detect interrupts */
#if defined(HAVE_HSMCI) && !defined(CONFIG_SAMV7_GPIOD_IRQ)
# warning PIOD interrupts not enabled. No MMC/SD support.
# undef HAVE_HSMCI
#endif
/* MMC/SD minor numbers */
#ifndef CONFIG_NSH_MMCSDMINOR
# define CONFIG_NSH_MMCSDMINOR 0
#endif
#ifndef CONFIG_NSH_MMCSDSLOTNO
# define CONFIG_NSH_MMCSDSLOTNO 0
#endif
#if CONFIG_NSH_MMCSDSLOTNO != 0
# error SAME70 has only one MMC/SD slot (CONFIG_NSH_MMCSDSLOTNO)
# undef CONFIG_NSH_MMCSDSLOTNO
# define CONFIG_NSH_MMCSDSLOTNO 0
#endif
#define HSMCI0_SLOTNO CONFIG_NSH_MMCSDSLOTNO
#define HSMCI0_MINOR CONFIG_NSH_MMCSDMINOR
/* Automounter. Currently only works with HSMCI. */
#if !defined(CONFIG_FS_AUTOMOUNTER) || !defined(HAVE_HSMCI)
# undef HAVE_AUTOMOUNTER
# undef CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT
#endif
#ifndef CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT
# undef HAVE_AUTOMOUNTER
#endif
#ifdef HAVE_AUTOMOUNTER
# ifdef CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT
/* HSMCI0 Automounter defaults */
# ifndef CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_FSTYPE
# define CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_FSTYPE "vfat"
# endif
# ifndef CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_BLKDEV
# define CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_BLKDEV "/dev/mmcds0"
# endif
# ifndef CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_MOUNTPOINT
# define CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_MOUNTPOINT "/mnt/sdcard0"
# endif
# ifndef CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_DDELAY
# define CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_DDELAY 1000
# endif
# ifndef CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_UDELAY
# define CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_UDELAY 2000
# endif
# endif /* CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT */
#endif /* HAVE_AUTOMOUNTER */
/* On-chip Programming Memory */
#if !defined(CONFIG_SAMV7_PROGMEM) || !defined(CONFIG_MTD_PROGMEM)
# undef HAVE_PROGMEM_CHARDEV
#endif
/* This is the on-chip progmem memory driver minor number */
#define PROGMEM_MTD_MINOR 0
/* procfs File System */
#ifdef CONFIG_FS_PROCFS
# ifdef CONFIG_NSH_PROC_MOUNTPOINT
# define SAME70_PROCFS_MOUNTPOINT CONFIG_NSH_PROC_MOUNTPOINT
# else
# define SAME70_PROCFS_MOUNTPOINT "/proc"
# endif
#endif
/* SAME70-QMTECH GPIO Pin Definitions ***************************************/
/* LEDs
*
* A single LED is available driven by PA15.
*/
#define GPIO_LED0 (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_SET | \
GPIO_PORT_PIOA | GPIO_PIN15)
/* Buttons
*
* SAM E70 QMTECH contains two mechanical buttons. One button is the RESET
* button connected to the SAM E70 reset line and the other, PA11, is a
* generic user configurable button.
* When a button is pressed it will drive the I/O line to GND.
*
* NOTE: There are no pull-up resistors connected to the generic user buttons
* so it is necessary to enable the internal pull-up in the SAM E70 to use
* the button.
*/
#define GPIO_SW0 (GPIO_INPUT | GPIO_CFG_PULLUP | GPIO_CFG_DEGLITCH | \
GPIO_INT_BOTHEDGES | GPIO_PORT_PIOA | GPIO_PIN21)
#define IRQ_SW0 SAM_IRQ_PA21
/* HSMCI SD Card Detect
*
* The SAM E70 QMTECH has one standard SD card connector that is connected
* to the High Speed Multimedia Card Interface (HSMCI) of the SAM E70. SD
* card connector:
*
* ------ ----------------- ---------------------
* SAME70 SAME70 Shared functionality
* Pin Function
* ------ ----------------- ---------------------
* PA30 MCDA0 (DAT0)
* PA31 MCDA1 (DAT1)
* PA26 MCDA2 (DAT2)
* PA27 MCDA3 (DAT3) Camera
* PA25 MCCK (CLK) Shield
* PA28 MCCDA (CMD)
* PD17 Card Detect (C/D) Shield
* ------ ----------------- ---------------------
*/
#define GPIO_MCI0_CD (GPIO_INPUT | GPIO_CFG_PULLDOWN | GPIO_CFG_DEGLITCH | \
GPIO_INT_BOTHEDGES | GPIO_PORT_PIOD | GPIO_PIN17)
#define IRQ_MCI0_CD SAM_IRQ_PD17
/****************************************************************************
* Public Types
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
#ifndef __ASSEMBLY__
/****************************************************************************
* Public Functions Definitions
****************************************************************************/
/****************************************************************************
* Name: sam_bringup
*
* Description:
* Bring up board features
*
****************************************************************************/
#if defined(CONFIG_BOARDCTL) || defined(CONFIG_BOARD_LATE_INITIALIZE)
int sam_bringup(void);
#endif
/****************************************************************************
* Name: sam_afec_initialize
*
* Description:
* Initialize and register the ADC driver.
*
****************************************************************************/
#ifdef CONFIG_SAMV7_AFEC
int sam_afec_setup(void);
#endif
/****************************************************************************
* Name: sam_dacdev_initialize
*
* Description:
* Called to configure DAC peripheral module
*
****************************************************************************/
#if defined(CONFIG_SAMV7_DAC0) || defined(CONFIG_SAMV7_DAC1)
int sam_dacdev_initialize(void);
#endif
/****************************************************************************
* Name: sam_spidev_initialize
*
* Description:
* Called to configure SPI chip select GPIO pins for the SAME70-QMTECH
* board.
*
****************************************************************************/
#ifdef CONFIG_SAMV7_SPI
void sam_spidev_initialize(void);
#endif
/****************************************************************************
* Name: sam_hsmci_initialize
*
* Description:
* Initialize HSMCI support
*
****************************************************************************/
#ifdef HAVE_HSMCI
int sam_hsmci_initialize(int slot, int minor);
#else
# define sam_hsmci_initialize(s,m) (-ENOSYS)
#endif
/****************************************************************************
* Name: sam_progmem_init
*
* Description:
* Initialize the FLASH and register the MTD device.
****************************************************************************/
#ifdef HAVE_PROGMEM_CHARDEV
int sam_progmem_init(void);
#endif
/****************************************************************************
* Name: sam_can_setup
*
* Description:
* Initialize CAN and register the CAN device
*
****************************************************************************/
#ifdef CONFIG_SAMV7_MCAN
int sam_can_setup(void);
#endif
/****************************************************************************
* Name: sam_cardinserted
*
* Description:
* Check if a card is inserted into the selected HSMCI slot
*
****************************************************************************/
#ifdef HAVE_HSMCI
bool sam_cardinserted(int slotno);
#else
# define sam_cardinserted(slotno) (false)
#endif
/****************************************************************************
* Name: sam_writeprotected
*
* Description:
* Check if the card in the MMCSD slot is write protected
*
****************************************************************************/
#ifdef HAVE_HSMCI
bool sam_writeprotected(int slotno);
#endif
/****************************************************************************
* Name: sam_automount_initialize
*
* Description:
* Configure auto-mounters for each enable and so configured HSMCI
*
* Input Parameters:
* None
*
* Returned Value:
* None
*
****************************************************************************/
#ifdef HAVE_AUTOMOUNTER
void sam_automount_initialize(void);
#endif
/****************************************************************************
* Name: sam_automount_event
*
* Description:
* The HSMCI card detection logic has detected an insertion or removal
* event. It has already scheduled the MMC/SD block driver operations.
* Now we need to schedule the auto-mount event which will occur with a
* substantial delay to make sure that everything has settle down.
*
* Input Parameters:
* slotno - Identifies the HSMCI0 slot: HSMCI0 or HSMCI1_SLOTNO.
* There is a terminology problem here: Each HSMCI supports two slots,
* slot A and slot B. Only slot A is used. So this is not a really a
* slot, but an HSCMI peripheral number.
* inserted - True if the card is inserted in the slot. False otherwise.
*
* Returned Value:
* None
*
* Assumptions:
* Interrupts are disabled.
*
****************************************************************************/
#ifdef HAVE_AUTOMOUNTER
void sam_automount_event(int slotno, bool inserted);
#endif
/****************************************************************************
* Name: sam_writeprotected
*
* Description:
* Check if the card in the MMCSD slot is write protected
*
****************************************************************************/
#ifdef HAVE_HSMCI
bool sam_writeprotected(int slotno);
#else
# define sam_writeprotected(slotno) (false)
#endif
#endif /* __ASSEMBLY__ */
#endif /* __BOARDS_ARM_SAMV7_SAME70_QMTECH_SRC_SAME70_QMTECH_H */

View file

@ -0,0 +1,13 @@
#
# Atmel SAME70 board from QMTECH.
# https://github.com/ChinaQMTECH/ATSAMS70_E70
#
# Connect using the EDBG chip on the dev kit over USB
source [find interface/cmsis-dap.cfg]
set CHIPNAME atsame70n19
source [find target/atsamv.cfg]
reset_config srst_only

View file

@ -0,0 +1,57 @@
#!/usr/bin/env bash
#
# See boards/atmel_same70_qmtech.cfg/README.txt for information about
# this file.
TOPDIR=$1
USAGE="$0 <TOPDIR> [-d]"
if [ -z "${TOPDIR}" ]; then
echo "Missing argument"
echo $USAGE
exit 1
fi
# Assume that OpenOCD was installed and at /usr/local/bin. Uncomment
# the following to run directly from the build directory
# OPENOCD_PATH="/home/OpenOCD/openocd/src"
# OPENOCD_PATH="/usr/bin"
OPENOCD_PATH="/usr/local/bin"
# TARGET_PATH="/home/OpenOCD/openocd/tcl"
# TARGET_PATH="/usr/share/openocd/scripts"
TARGET_PATH="/usr/local/share/openocd/scripts"
# Assume a Unix development environment. Uncomment to use a Windows
# like environment
#OPENOCD_EXE=openocd.exe
OPENOCD_EXE=openocd
OPENOCD_CFG="${TOPDIR}/boards/arm/samv7/same70-qmtech/tools/atmel_same70_qmtech.cfg"
OPENOCD_ARGS="-f ${OPENOCD_CFG} -s ${TARGET_PATH}"
if [ "X$2" = "X-d" ]; then
OPENOCD_ARGS=$OPENOCD_ARGS" -d3"
set -x
fi
if [ ! -d ${OPENOCD_PATH} ]; then
echo "OpenOCD path does not exist: ${OPENOCD_PATH}"
exit 1
fi
if [ ! -x ${OPENOCD_PATH}/${OPENOCD_EXE} ]; then
echo "OpenOCD does not exist: ${OPENOCD_PATH}/${OPENOCD_EXE}"
exit 1
fi
if [ ! -f ${OPENOCD_CFG} ]; then
echo "OpenOCD config file does not exist: ${OPENOCD_CFG}"
exit 1
fi
echo "Starting OpenOCD"
cd ${OPENOCD_PATH} || { echo "Failed to CD to ${OPENOCD_PATH}"; exit 1; }
${OPENOCD_EXE} ${OPENOCD_ARGS} &
echo "OpenOCD daemon started"
ps -ef | grep openocd
echo "In GDB: target remote localhost:3333"