/
README.txt
3857 lines (2975 loc) · 159 KB
/
README.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
README
======
This README file describes the port of NuttX to the SAMA5D3x-EK
development boards. These boards feature the Atmel SAMA5D3
microprocessors. Four different SAMA5D3x-EK kits are available
- SAMA5D31-EK with the ATSAMA5D31 (http://www.atmel.com/devices/sama5d31.aspx)
- SAMA5D33-EK with the ATSAMA5D33 (http://www.atmel.com/devices/sama5d33.aspx)
- SAMA5D34-EK with the ATSAMA5D34 (http://www.atmel.com/devices/sama5d34.aspx)
- SAMA5D35-EK with the ATSAMA5D35 (http://www.atmel.com/devices/sama5d35.aspx)
The each consist of an identical base board with different plug-in
modules for each CPU. I also have a 5 inch LCD for my SAMA5D3x-EK,
Atmel 5.0_WVGA_R_AEA_DM, Rev. B, but this LCD is not yet generally available
as of this writing.
I have seen SAMA5D3x-EK boards with different LCDs attached. One of the more
common LCDS is the 7 inch TM0000 TFT LCD controller with MaXTouch multi-touch,
capacitive touchscreen (http://www.pdaatl.com/doc/tm7000.pdf). That is NOT the
LCD supported by this configuration; the LCD used here is smaller and has a
resistive touchscreen that interfaces via the SAMA5D3 ADC interface. Refer to
the SAMA5D4-EK for TM0000 support that can be back-ported to the SAMA5D3x-EK.
SAMA5D3 Family
ATSAMA5D31 ATSAMA5D33 ATSAMA5D34 ATSAMA5D35
------------------------- ------------- ------------- ------------- -------------
Pin Count 324 324 324 324
Max. Operating Frequency 536 536 536 536
CPU Cortex-A5 Cortex-A5 Cortex-A5 Cortex-A5
Max I/O Pins 160 160 160 160
Ext Interrupts 160 160 160 160
USB Transceiver 3 3 3 3
USB Speed Hi-Speed Hi-Speed Hi-Speed Hi-Speed
USB Interface Host, Device Host, Device Host, Device Host, Device
SPI 6 6 6 6
TWI (I2C) 3 3 3 3
UART 7 5 5 7
CAN - - 2 2
LIN 4 4 4 4
SSC 2 2 2 2
Ethernet 1 1 1 2
SD / eMMC 3 2 3 3
Graphic LCD Yes Yes Yes -
Camera Interface Yes Yes Yes Yes
ADC channels 12 12 12 12
ADC Resolution (bits) 12 12 12 12
ADC Speed (ksps) 440 440 440 440
Resistive Touch Screen Yes Yes Yes Yes
Crypto Engine AES/DES/ AES/DES/ AES/DES/ AES/DES/
SHA/TRNG SHA/TRNG SHA/TRNG SHA/TRNG
SRAM (Kbytes) 128 128 128 128
External Bus Interface 1 1 1 1
DRAM Memory DDR2/LPDDR, DDR2/LPDDR, DDR2/LPDDR, DDR2/LPDDR,
SDRAM/LPSDR SDRAM/LPSDR DDR2/LPDDR, DDR2/LPDDR,
NAND Interface Yes Yes Yes Yes
Temp. Range (deg C) -40 to 85 -40 to 85 -40 to 85 -40 to 85
I/O Supply Class 1.8/3.3 1.8/3.3 1.8/3.3 1.8/3.3
Operating Voltage (Vcc) 1.08 to 1.32 1.08 to 1.32 1.08 to 1.32 1.08 to 1.32
FPU Yes Yes Yes Yes
MPU / MMU No/Yes No/Yes No/Yes No/Yes
Timers 5 5 5 6
Output Compare channels 6 6 6 6
Input Capture Channels 6 6 6 6
PWM Channels 4 4 4 4
32kHz RTC Yes Yes Yes Yes
Packages LFBGA324_A LFBGA324_A LFBGA324_A LFBGA324_A
Contents
========
- Development Environment
- GNU Toolchain Options
- IDEs
- NuttX EABI "buildroot" Toolchain
- NXFLAT Toolchain
- Loading Code into SRAM with J-Link
- Writing to FLASH using SAM-BA
- Creating and Using NORBOOT
- Running NuttX from SDRAM
- Buttons and LEDs
- Serial Consoles
- Networking
- AT25 Serial FLASH
- HSMCI Card Slots
- Auto-Mounter
- USB Ports
- USB High-Speed Device
- USB High-Speed Host
- SDRAM Support
- NAND Support
- AT24 Serial EEPROM
- I2C Tool
- CAN Usage
- SAMA5 ADC Support
- SAMA5 PWM Support
- RTC
- Watchdog Timer
- TRNG and /dev/random
- Touchscreen Testing
- Tickless OS
- OV2640 Camera Interface
- I2S Audio Support
- SAMA5D3x-EK Configuration Options
- Configurations
- To-Do List
Development Environment
=======================
Several possible development environments may be used:
- Linux or macOS native
- Cygwin unders Windows
- MinGW + MSYS under Windows
- Windows native (with GNUMake from GNUWin32).
All testing has been performed using Cygwin under Windows.
The source has been built only using the GNU toolchain (see below). Other
toolchains will likely cause problems.
GNU Toolchain Options
=====================
The NuttX make system will support the several different toolchain options.
All testing has been conducted using the CodeSourcery GCC toolchain. To use
a different toolchain, you simply need to add change to one of the following
configuration options to your .config (or defconfig) file:
CONFIG_ARM_TOOLCHAIN_BUILDROOT=y : NuttX buildroot under Linux or Cygwin (default)
CONFIG_ARM_TOOLCHAIN_GNU_EABI=y : Generic GCC ARM EABI toolchain
IDEs
====
NuttX is built using command-line make. It can be used with an IDE, but some
effort will be required to create the project.
Makefile Build
--------------
Under Eclipse, it is pretty easy to set up an "empty makefile project" and
simply use the NuttX makefile to build the system. That is almost for free
under Linux. Under Windows, you will need to set up the "Cygwin GCC" empty
makefile project in order to work with Windows (Google for "Eclipse Cygwin" -
there is a lot of help on the internet).
Native Build
------------
Here are a few tips before you start that effort:
1) Select the toolchain that you will be using in your .config file
2) Start the NuttX build at least one time from the Cygwin command line
before trying to create your project. This is necessary to create
certain auto-generated files and directories that will be needed.
3) Set up include paths: You will need include/, arch/arm/src/sam34,
arch/arm/src/common, arch/arm/src/armv7-m, and sched/.
4) All assembly files need to have the definition option -D __ASSEMBLY__
on the command line.
Startup files will probably cause you some headaches. The NuttX startup file
is arch/arm/src/sam34/sam_vectors.S. You may need to build NuttX
one time from the Cygwin command line in order to obtain the pre-built
startup object needed by an IDE.
NuttX EABI "buildroot" Toolchain
================================
A GNU GCC-based toolchain is assumed. The PATH environment variable should
be modified to point to the correct path to the Cortex-M3 GCC toolchain (if
different from the default in your PATH variable).
If you have no Cortex-M3 toolchain, one can be downloaded from the NuttX
Bitbucket download site (https://bitbucket.org/nuttx/buildroot/downloads/).
This GNU toolchain builds and executes in the Linux or Cygwin environment.
1. You must have already configured NuttX in <some-dir>/nuttx.
tools/configure.sh sama5d3x-ek:<sub-dir>
2. Download the latest buildroot package into <some-dir>
3. unpack the buildroot tarball. The resulting directory may
have versioning information on it like buildroot-x.y.z. If so,
rename <some-dir>/buildroot-x.y.z to <some-dir>/buildroot.
4. cd <some-dir>/buildroot
5. Copy the configuration file from the boards/ sub-directory to the
top-level build directory:
cp boards/cortexa8-eabi-defconfig-4.8.2 .config
6a. You may wish to modify the configuration before you build it. For
example, it is recommended that you build the kconfig-frontends tools,
generomfs, and the NXFLAT tools as well. You may also want to change
the selected toolchain. These reconfigurations can all be done with
make menuconfig
6b. If you chose to make the configuration with no changes, then you
should still do the following to make certain that the build
configuration is up-to-date:
make oldconfig
7. make
8. Make sure that the PATH variable includes the path to the newly built
binaries.
See the file boards/README.txt in the buildroot source tree. That has more
details PLUS some special instructions that you will need to follow if you are
building a Cortex-M3 toolchain for Cygwin under Windows.
NXFLAT Toolchain
================
If you are *not* using the NuttX buildroot toolchain and you want to use
the NXFLAT tools, then you will still have to build a portion of the buildroot
tools -- just the NXFLAT tools. The buildroot with the NXFLAT tools can
be downloaded from the NuttX Bitbucket download site
(https://bitbucket.org/nuttx/nuttx/downloads/).
This GNU toolchain builds and executes in the Linux or Cygwin environment.
1. You must have already configured NuttX in <some-dir>/nuttx.
tools/configure.sh sama5d3x-ek:<sub-dir>
2. Download the latest buildroot package into <some-dir>
3. unpack the buildroot tarball. The resulting directory may
have versioning information on it like buildroot-x.y.z. If so,
rename <some-dir>/buildroot-x.y.z to <some-dir>/buildroot.
4. cd <some-dir>/buildroot
5. cp boards/cortexm3-defconfig-nxflat .config
6. make oldconfig
7. make
8. Make sure that the PATH variable includes the path to the newly built
NXFLAT binaries.
NOTE: There are some known incompatibilities with 4.6.3 EABI toolchain
and the NXFLAT tools. See the top-level TODO file (under "Binary
loaders") for more information about this problem. If you plan to use
NXFLAT, please do not use the GCC 4.6.3 EABI toochain.
Loading Code into SRAM with J-Link
==================================
Loading code with the Segger tools and GDB
------------------------------------------
1) Change directories into the directory where you built NuttX.
2) Start the GDB server and wait until it is ready to accept GDB
connections.
3) Then run GDB like this:
$ arm-none-eabi-gdb
(gdb) target remote localhost:2331
(gdb) mon reset
(gdb) load nuttx
(gdb) ... start debugging ...
Loading code using J-Link Commander
----------------------------------
J-Link> r
J-Link> loadbin <file> <address>
J-Link> setpc <address of __start>
J-Link> ... start debugging ...
Writing to FLASH using SAM-BA
=============================
Assumed starting configuration:
1. You have installed the J-Link CDC USB driver (Windows only, there is
no need to install a driver on any regular Linux distribution),
2. You have the USB connected to DBGU port (J14)
3. Terminal configuration: 115200 8N1
Using SAM-BA to write to FLASH:
1. Exit the terminal emulation program and remove the USB cable from
the DBGU port (J14)
2. Connect the USB cable to the device USB port (J20)
3. JP9 must open (BMS == 1) to boot from on-chip Boot ROM.
4. Press and maintain PB4 CS_BOOT button and power up the board. PB4
CS_BOOT button prevents booting from Nand or serial Flash by
disabling Flash Chip Selects after having powered the board, you can
release the PB4 BS_BOOT button.
5. On Windows you may need to wait for a device driver to be installed.
6. Start the SAM-BA application, selecting (1) the correct USB serial
port, and (2) board = at91sama5d3x-ek.
7. The SAM-BA menu should appear.
8. Select the FLASH bank that you want to use and the address to write
to and "Execute"
9. When you are finished writing to FLASH, remove the USB cable from J20
and re-connect the serial link on USB CDC / DBGU connector (J14) and
re-open the terminal emulator program.
10. If you loaded code in NOR flash (CS0), then you will need to close
JP9 (BMS == 0) to force booting out of NOR flash (see NOTE).
11. Power cycle the board.
NOTES: By closing JP9 (BMS == 0), you can force the board to boot
directly to NOR FLASH. Executing from other memories will require that
you provide a special code header so that you code can be recognized as a
boot-able image by the ROM bootloader.
Creating and Using NORBOOT
==========================
In order to have more control of debugging code that runs out of NOR FLASH,
I created the sama5d3x-ek/norboot configuration. That configuration is
described below under "Configurations."
Here are some general instructions on how to build an use norboot:
Building:
1. Remove any old configurations (if applicable).
cd <nuttx>
make distclean
2. Install and build the norboot configuration. This steps will establish
the norboot configuration and setup the PATH variable in order to do
the build:
tools/configure.sh sama5d3x-ek:<subdir>
Before building, make sure the PATH environment variable includes the
correct path to the directory than holds your toolchain binaries.
NOTE: Be aware that the default norboot also disables the watchdog.
Since you will not be able to re-enable the watchdog later, you may
need to set CONFIG_SAMA5_WDT=y in the NuttX configuration file.
Then make norboot:
make
This will result in an ELF binary called 'nuttx' and also HEX and
binary versions called 'nuttx.hex' and 'nuttx.bin'.
3. Rename the binaries. Since you will need two versions of NuttX: this
norboot version that runs in internal SRAM and another under test in
NOR FLASH, I rename the resulting binary files so that they can be
distinguished:
mv nuttx norboot
mv nuttx.hex norboot.hex
mv nuttx.bin norboot.bin
4. Build your NOR configuration and write this into NOR FLASH. Here, for
example, is how you would create the NSH NOR configuration:
cd <nuttx>
make distclean # Remove the norboot configuration
tools/configure.sh sama5d3x-ek/nsh # Establish the NSH configuration
make # Build the NSH configuration
Then use SAM-BA to write the nuttx.bin binary into NOR FLASH. This
will involve holding the CS_BOOT button and power cycling to start
the ROM loader. The SAM-BA serial connection will be on the device
USB port, not the debug USB port. Follow the SAM-BA instruction to
write the nuttx.bin binary to NOR FLASH.
5. Restart the system without holding CS_BOOT to get back to the normal
debug setup.
6. Then start the J-Link GDB server and GDB. In GDB, I do the following:
(gdb) mon reset # Reset and halt the CPU
(gdb) load norboot # Load norboot into internal SRAM
(gdb) mon go # Start norboot
(gdb) mon halt # Break in
(gdb) mon reg pc = 0x10000040 # Set the PC to NOR flash entry point
(gdb) mon go # And jump into NOR flash
The norboot program can also be configured to jump directly into
NOR FLASH without requiring the final halt and go by setting
CONFIG_SAMA5D3XEK_NOR_START=y in the NuttX configuration. However,
since I have been debugging the early boot sequence, the above
sequence has been most convenient for me since it allows me to
step into the program in NOR.
7. An option is to use the SAM-BA tool to write the NORBOOT image into
Serial FLASH. Then, the system will boot from Serial FLASH by
copying the NORBOOT image in SRAM which will run and then start the
image in NOR FLASH automatically. This is a very convenient usage!
NOTES: (1) There is jumper on the CM module that must be closed to
enable use of the AT25 Serial Flash. (2) If using SAM-BA, make sure
that you load the NOR boot program into the boot area via the pull-
down menu.
STATUS:
2013-7-30: I have been unable to execute these configurations from NOR
FLASH by closing the BMS jumper (J9). As far as I can tell, this
jumper does nothing on my board??? So I have been using the norboot
configuration exclusively to start the program-under-test in NOR FLASH.
Running NuttX from SDRAM
========================
Executing from SDRAM
--------------------
NuttX may be executed from SDRAM. But this case means that the NuttX
binary must reside on some other media (typically NAND FLASH, Serial
FLASH, or, perhaps even a TFTP server). In these cases, an intermediate
bootloader such as U-Boot or Barebox must be used to configure the
SAMA5D3 clocks and SDRAM and then to copy the NuttX binary into SDRAM.
- NuttX Configuration
- Boot sequence
- NAND FLASH Memory Map
- Programming the AT91Boostrap Binary
- Programming U-Boot
- Load NuttX with U-Boot on AT91 boards
TODO: Some drivers may require some adjustments to run from SDRAM. That
is because in this case macros like BOARD_MCK_FREQUENCY are not constants
but are instead function calls: The MCK clock frequency is not known in
advance but instead has to be calculated from the bootloader PLL configuration.
See the TODO list at the end of this file for further information.
Using JTAG
----------
This description assumes that you have a JTAG debugger such as Segger
J-Link connected to the SAMA5D3-Xplained.
1. Start the GDB server
2. Start GDB
3. Use the 'target remote localhost:xxxx' command to attach to the GDG
server
4. Do 'mon reset' then 'mon go' to start the internal boot loader (maybe
U-Boot).
5. Let the boot loader run until it completes SDRAM initialization, then
do 'mon halt'.
6. Now you have SDRAM initialized and you use 'load nuttx' to load the
ELF file into SDRAM.
7. Use 'file nuttx' to load symbols
8. Set the PC to the NuttX entry point 'mon pc 0x20008040' and start
nuttx using 'mon go'.
NuttX Configuration
-------------------
In order to run from SDRAM, NuttX must be built at origin 0x20008000 in
SDRAM (skipping over SDRAM memory used by the bootloader). The following
configuration option is required:
CONFIG_SAMA5_BOOT_SDRAM=y
CONFIG_BOOT_RUNFROMSDRAM=y
These options tell the NuttX code that it will be booting and running from
SDRAM. In this case, the start-logic will do to things: (1) it will not
configure the SAMA5D3 clocking. Rather, it will use the clock configuration
as set up by the bootloader. And (2) it will not attempt to configure the
SDRAM. Since NuttX is already running from SDRAM, it must accept the SDRAM
configuration as set up by the bootloader.
Boot sequence
-------------
Reference: http://www.at91.com/linux4sam/bin/view/Linux4SAM/GettingStarted
Several pieces of software are involved to boot a Nutt5X into SDRAM. First
is the primary bootloader in ROM which is in charge to check if a valid
application is present on supported media (NOR FLASH, Serial DataFlash,
NAND FLASH, SD card).
The boot sequence of linux4SAM is done in several steps :
1. The ROM bootloader checks if a valid application is present in FLASH
and if it is the case downloads it into internal SRAM. This program
is usually a second level bootloader called AT91BootStrap.
2. AT91Bootstrap is the second level bootloader. It is in charge of the
hardware configuration. It downloads U-Boot / Barebox binary from
FLASH to SDRAM / DDRAM and starts the third level bootloader
(U-Boot / Barebox)
(see http://www.at91.com/linux4sam/bin/view/Linux4SAM/AT91Bootstrap).
3. The third level bootloader is either U-Boot or Barebox. The third
level bootloader is in charge of downloading NuttX binary from FLASH,
network, SD card, etc. It then starts NuttX.
4. Then NuttX runs from SDRAM
DRAMBOOT
--------
See also Documentation/platforms/arm/sama5/boards/sama5d4-ek/README.txt for a description of the DRAMBOOT
program. This is a tiny version of NuttX that can run out of internal
SRAM. If you put this program on the HSMCI1 microSD card as boot.bin, then
it will boot on power up and you can download NuttX directly into DRAM by
sending the nuttx.hex file over the serial connection.
The Documentation/platforms/arm/sama5/boards/sama5d4-ek/README.txt also describes variants AT25BOOT and
SRAMBOOT. This have not been ported to the SAMA5D3x-EK, but are available
if they are useful too you.
NAND FLASH Memory Map
---------------------
Reference: http://www.at91.com/linux4sam/bin/view/Linux4SAM/GettingStarted
0x0000:0000 - 0x0003:ffff: AT91BootStrap
0x0004:0000 - 0x000b:ffff: U-Boot
0x000c:0000 - 0x000f:ffff: U-Boot environment
0x0010:0000 - 0x0017:ffff: U-Boot environment redundant
0x0018:0000 - 0x001f:ffff: Device tree (DTB)
0x0020:0000 - 0x007f:ffff: NuttX
0x0080:0000 - end: Available for use as a NAND file system
Programming the AT91Boostrap Binary
-----------------------------------
Reference: http://www.at91.com/linux4sam/bin/view/Linux4SAM/AT91Bootstrap
This section describes how to program AT91Bootstrap binary into the boot
media with SAM-BA tool using NandFlash as boot media.
1. Get AT91BootStrap binaries. Build instructions are available here:
http://www.at91.com/linux4sam/bin/view/Linux4SAM/AT91Bootstrap#Build_AT91Bootstrap_from_sources
A pre-built AT91BootStrap binary is available here:
ftp://www.at91.com/pub/at91bootstrap/AT91Bootstrap3.6.0/sama5d3xek-nandflashboot-uboot-3.6.0.bin
2. Start the SAM-BA GUI Application:
- Connect the USB Device interface to your host machine using the USB
Device Cable.
- Make sure that the chip can execute the SAM-BA Monitor.
- Start SAM-BA GUI application.
- Select the board in the drop-down menu and choose the USB connection.
3. In the SAM-BA GUI Application:
- Choose the "NandFlash" tab in the SAM-BA GUI interface.
- Initialize the NandFlash by choosing the "Enable NandFlash" action in
the Scripts rolling menu, then press "Execute" button.
- Erase the NandFlash device by choosing the "Erase All" action, then
press "Execute" button.
- Enable the PMECC by choosing the "Enable OS PMECC parameters" action,
then press "Execute" button.
PMECC
Number of sectors per page: 4
Spare Size: 64
Number of ECC bits required: 4
Size of the ECC sector: 512
ECC offset: 36
- Choose "Send Boot File" action, then press Execute button to select the
at91bootstrap binary file and to program the binary to the NandFlash.
- Close SAM-BA, remove the USB Device cable.
Programming U-Boot
-------------------
Reference http://www.at91.com/linux4sam/bin/view/Linux4SAM/U-Boot
1. Get U-Boot Binaries. Build instructions are available here:
http://www.at91.com/linux4sam/bin/view/Linux4SAM/U-Boot#Build_U_Boot_from_sources
A pre-built binary is available here:
ftp://www.at91.com/pub/uboot/u-boot-v2012.10/u-boot-sama5d3xek_nandflash_linux4sam_4.2.bin
2. Start the SAM-BA GUI Application:
- Connect the USB Device interface to your host machine using the USB
Device Cable.
- Make sure that the chip can execute the SAM-BA Monitor.
- Start SAM-BA GUI application.
- Select the board in the drop-down menu and choose the USB connection.
3. In the SAM-BA GUI Application:
- Choose the NandFlash tab in the SAM-BA GUI interface.
- Initialize the NandFlash by choosing the "Enable NandFlash" action in
the Scripts rolling menu, then press Execute button.
- Enable the PMECC by choosing the "Enable OS PMECC parameters" action,
then press Execute button.
PMECC
Number of sectors per page: 4
Spare Size: 64
Number of ECC bits required: 4
Size of the ECC sector: 512
ECC offset: 36
- Press the "Send File Name" Browse button
- Choose u-boot.bin binary file and press Open
- Enter the proper address on media in the Address text field:
0x00040000
- Press the "Send File" button
- Close SAM-BA, remove the USB Device cable.
You should now be able to interrupt with U-Boot via the DBGU interface.
Load NuttX with U-Boot on AT91 boards
-------------------------------------
Reference http://www.at91.com/linux4sam/bin/view/Linux4SAM/U-Boot
Preparing NuttX image
U-Boot does not support normal binary images. Instead you have to
create an uImage file with the mkimage tool which encapsulates kernel
image with header information, CRC32 checksum, etc.
mkimage comes in source code with U-Boot distribution and it is built
during U-Boot compilation (u-boot-source-dir/tools/mkimage). There
are also sites where you can download pre-built mkimage binaries. For
example: http://www.trimslice.com/wiki/index.php/U-Boot_images
See the U-Boot README file for more information. More information is
also available in the mkimage man page (for example,
http://linux.die.net/man/1/mkimage).
Command to generate an uncompressed uImage file (4) :
mkimage -A arm -O linux -C none -T kernel -a 20008000 -e 20008000 \
-n nuttx -d nuttx.bin uImage
Where:
-A arm: Set architecture to ARM
-O linux: Select operating system. bootm command of u-boot changes
boot method by os type.
-T kernel: Set image type.
-C none: Set compression type.
-a 20008000: Set load address.
-e 20008000: Set entry point.
-n nuttx: Set image name.
-d nuttx.bin: Use image data from nuttx.bin.
This will generate a binary called uImage. If you have the path to
mkimage in your PATH variable, then you can automatically build the
uImage file by adding the following to your .config file:
CONFIG_RAW_BINARY=y
CONFIG_UBOOT_UIMAGE=y
CONFIG_UIMAGE_LOAD_ADDRESS=0x20008000
CONFIG_UIMAGE_ENTRY_POINT=0x20008040
The uImage file can them be loaded into memory from a variety of sources
(serial, SD card, JFFS2 on NAND, TFTP).
STATUS:
2014-4-1: So far, I am unable to get U-Boot to execute the uImage
file. I get the following error messages (in this case
trying to load from an SD card):
U-Boot> fatload mmc 0 0x22000000 uimage
reading uimage
97744 bytes read in 21 ms (4.4 MiB/s)
U-Boot> bootm 0x22000000
## Booting kernel from Legacy Image at 0x22000000 ...
Image Name: nuttx
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 97680 Bytes = 95.4 KiB
Load Address: 20008000
Entry Point: 20008040
Verifying Checksum ... OK
XIP Kernel Image ... OK
FDT and ATAGS support not compiled in - hanging
### ERROR ### Please RESET the board ###
This, however, appears to be a usable workaround:
U-Boot> fatload mmc 0 0x20008000 nuttx.bin
mci: setting clock 257812 Hz, block size 512
mci: setting clock 257812 Hz, block size 512
mci: setting clock 257812 Hz, block size 512
gen_atmel_mci: CMDR 00001048 ( 8) ARGR 000001aa (SR: 0c100025) Command Time Out
mci: setting clock 257812 Hz, block size 512
mci: setting clock 22000000 Hz, block size 512
reading nuttx.bin
108076 bytes read in 23 ms (4.5 MiB/s)
U-Boot> go 0x20008040
## Starting application at 0x20008040 ...
NuttShell (NSH) NuttX-7.2
nsh>
Loading through network
On a development system, it is useful to get the kernel and root file
system through the network. U-Boot provides support for loading
binaries from a remote host on the network using the TFTP protocol.
To manage to use TFTP with U-Boot, you will have to configure a TFTP
server on your host machine. Check your distribution manual or Internet
resources to configure a Linux or Windows TFTP server on your host:
- U-Boot documentation on a Linux host:
http://www.denx.de/wiki/view/DULG/SystemSetup#Section_4.6.
- Another TFTP configuration reference:
http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch16_:_Telnet%2C_TFTP%2C_and_xinetd#TFTP
On the U-Boot side, you will have to setup the networking parameters:
1. Setup an Ethernet address (MAC address)
Check this U-Boot network BuildRootFAQ entry to choose a proper MAC
address: http://www.denx.de/wiki/DULG/EthernetDoesNotWork
setenv ethaddr 00:e0:de:ad:be:ef
2. Setup IP parameters:
The board ip address
setenv ipaddr 10.0.0.2
The server ip address where the TFTP server is running
setenv serverip 10.0.0.1
3. saving Environment to flash
saveenv
4. If Ethernet Phy has not been detected during former bootup, reset
the board to reload U-Boot : the Ethernet address and Phy
initialization shall be ok, now
5. Download the NuttX uImage and the root file system to a ram location
using the U-Boot tftp command (Cf. U-Boot script capability chapter).
6. Launch NuttX issuing a bootm or boot command.
If the board has both emac and gmac, you can use following to choose
which one to use:
setenv ethact macb0,gmacb0
setenv ethprime gmacb0
STATUS:
2014-3-30: These instructions were adapted from the Linux4SAM website
but have not yet been used.
Buttons and LEDs
================
Buttons
-------
There are five push button switches on the SAMA5D3X-EK base board:
1. One Reset, board reset (BP1)
2. One Wake up, push button to bring the processor out of low power mode
(BP2)
3. One User momentary Push Button
4. One Disable CS Push Button
Only the momentary push button is controllable by software (labeled
"PB_USER1" on the board):
- PE27. Pressing the switch connects PE27 to grounded. Therefore, PE27
must be pulled high internally. When the button is pressed the SAMA5
will sense "0" is on PE27.
LEDs
----
There are two LEDs on the SAMA5D3 series-CM board that can be controlled
by software. A blue LED is controlled via PIO pins. A red LED normally
provides an indication that power is supplied to the board but can also
be controlled via software.
PE25. This blue LED is pulled high and is illuminated by pulling PE25
low.
PE24. The red LED is also pulled high but is driven by a transistor so
that it is illuminated when power is applied even if PE24 is not
configured as an output. If PE24 is configured as an output, then the
LED is illuminated by a high output.
N.B. PE24 Drives the RED Led on the CM (SODIMM200), but unfortunately
it is also connected to ISI_RST on the MB (Main Board) and controlling
it will reset a Camera connected to the ISI
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_leds.c. The LEDs are used to encode OS-related
events as follows when the red LED (PE24) is available:
SYMBOL Meaning LED state
Blue Red
------------------- ----------------------- -------- --------
LED_STARTED NuttX has been started OFF OFF
LED_HEAPALLOCATE Heap has been allocated OFF OFF
LED_IRQSENABLED Interrupts enabled OFF OFF
LED_STACKCREATED Idle stack created ON OFF
LED_INIRQ In an interrupt -- No change --
LED_SIGNAL In a signal handler -- No change --
LED_ASSERTION An assertion failed -- No change --
LED_PANIC The system has crashed OFF Blinking
LED_IDLE MCU is is sleep mode -- Not used --
If CONFIG_SAMA5D3XEK_NOREDLED=y, then the red LED is not used by the
system and the controls are as follows:
SYMBOL Meaning LED state
Blue Red
------------------- ----------------------- ----------- -----------
LED_STARTED NuttX has been started OFF Not used
LED_HEAPALLOCATE Heap has been allocated OFF " " " "
LED_IRQSENABLED Interrupts enabled OFF " " " "
LED_STACKCREATED Idle stack created ON " " " "
LED_INIRQ In an interrupt No change " " " "
LED_SIGNAL In a signal handler No change " " " "
LED_ASSERTION An assertion failed No change " " " "
LED_PANIC The system has crashed Blinking " " " "
LED_IDLE MCU is is sleep mode Not used " " " "
Thus if the blue LED is statically on, NuttX has successfully booted and
is, apparently, running normally. If the red (or blue) LED is flashing
at approximately 2Hz, then a fatal error has been detected and the system
has halted.
Serial Consoles
===============
USART1
------
By default USART1 is used as the NuttX serial console in all
configurations (unless otherwise noted). USART1 is buffered with an
RS-232 Transceiver (Analog Devices ADM3312EARU) and connected to the DB-9
male socket (J8).
USART1 Connector J8
-------------------------------
SAMA5 FUNCTION NUTTX PIO
PIO NAME CONFIGURATION
---- ---------- ---------------
PB27 RTS1 PIO_USART1_RTS
PB29 TXD1 PIO_USART1_TXD
PB28 RXD1 PIO_USART1_RXD
PB26 CTS1 PIO_USART1_CTS
NOTE: Debug TX (DTXD) and RX (DRXD) pins also are routed to the
ADM3312EARU via non populated 0 Ohm resistors. Thus allowing one
skilled with a soldering iron to choose which UART is level
translated by the ADM3312EARU
-------------------------------
SAMA5 FUNCTION NUTTX PIO
PIO NAME CONFIGURATION
---- ---------- ---------------
PB31 DTXD PIO_DBGU_DTXD
PB30 DRXD PIO_DBGU_DRXD
Hardware UART via CDC
---------------------
"J-Link-OB-ATSAM3U4C comes with an additional hardware UART that is
accessible from a host via CDC which allows terminal communication with
the target device. This feature is enabled only if a certain port (CDC
disabled, PA25, pin 24 on J-Link-OB-ATSAM3U4C) is NOT connected to ground
(open).
- Jumper JP16 not fitted: CDC is enabled
- Jumper JP16 fitted : CDC is disabled"
Networking
==========
Networking support via the can be added to NSH by selecting the following
configuration options. The SAMA5D3x supports two different Ethernet MAC
peripherals: (1) The 10/100Base-T EMAC peripheral and (2) the
10/100/1000Base-T GMAC peripheral. Only the SAMA5D31 and SAMAD35 support
the EMAC peripheral; Only the SAMA5D33, SAMA5D34, and SAMA5D35 support
the GMAC perpheral! NOTE that the SAMA5D35 supports both!
Selecting the EMAC peripheral
-----------------------------
System Type
CONFIG_ARCH_CHIP_ATSAMA5D31=y : SAMA5D31 or SAMAD35 support EMAC
CONFIG_ARCH_CHIP_ATSAMA5D35=y : (others do not)
System Type -> SAMA5 Peripheral Support
CONFIG_SAMA5_EMACA=y : Enable the EMAC (type A) peripheral
System Type -> EMAC device driver options
CONFIG_SAMA5_EMAC_NRXBUFFERS=16 : Set aside some RS and TX buffers
CONFIG_SAMA5_EMAC_NTXBUFFERS=4
CONFIG_SAMA5_EMAC_PHYADDR=1 : KSZ8021/31 PHY is at address 1
CONFIG_SAMA5_EMAC_AUTONEG=y : Use autonegotiation
CONFIG_SAMA5_EMAC_RMII=y : Either MII or RMII interface should work
CONFIG_SAMA5_EMAC_PHYSR=30 : Address of PHY status register on KSZ8021/31
CONFIG_SAMA5_EMAC_PHYSR_ALTCONFIG=y : Needed for KSZ8021/31
CONFIG_SAMA5_EMAC_PHYSR_ALTMODE=0x7 : " " " " " "
CONFIG_SAMA5_EMAC_PHYSR_10HD=0x1 : " " " " " "
CONFIG_SAMA5_EMAC_PHYSR_100HD=0x2 : " " " " " "
CONFIG_SAMA5_EMAC_PHYSR_10FD=0x5 : " " " " " "
CONFIG_SAMA5_EMAC_PHYSR_100FD=0x6 : " " " " " "
PHY selection. Later in the configuration steps, you will need to select
the KSZ8021/31 PHY for EMAC (See below)
Selecting the GMAC peripheral
-----------------------------
System Type
CONFIG_ARCH_CHIP_ATSAMA5D33=y : SAMA5D31, SAMA5D33 and SAMAD35
CONFIG_ARCH_CHIP_ATSAMA5D34=y : support GMAC (others do not)
CONFIG_ARCH_CHIP_ATSAMA5D35=y :
System Type -> SAMA5 Peripheral Support
CONFIG_SAMA5_GMAC=y : Enable the GMAC peripheral
System Type -> GMAC device driver options
CONFIG_SAMA5_GMAC_NRXBUFFERS=16 : Set aside some RS and TX buffers
CONFIG_SAMA5_GMAC_NTXBUFFERS=4
CONFIG_SAMA5_GMAC_PHYADDR=1 : KSZ8051 PHY is at address 1
CONFIG_SAMA5_GMAC_AUTONEG=y : Use autonegotiation
If both EMAC and GMAC are selected, you will also need:
CONFIG_SAMA5_GMAC_ISETH0=y : GMAC is "eth0"; EMAC is "eth1"
PHY selection. Later in the configuration steps, you will need to select
the KSZ9021/31 PHY for GMAC (See below)
Common configuration settings
-----------------------------
Networking Support
CONFIG_NET=y : Enable Networking
CONFIG_NET_SOCKOPTS=y : Enable socket operations
CONFIG_NET_ETH_PKTSIZE=562 : Maximum packet size 1518 is more standard
CONFIG_NET_TCP=y : Enable TCP/IP networking
CONFIG_NET_TCPBACKLOG=y : Support TCP/IP backlog
CONFIG_NET_UDP=y : Enable UDP networking
CONFIG_NET_ICMP=y : Enable ICMP networking
CONFIG_NET_ICMP_SOCKET=y : Needed for NSH ping command
: Defaults should be okay for other options
Device drivers -> Network Device/PHY Support
CONFIG_NETDEVICES=y : Enabled PHY selection
CONFIG_ETH0_PHY_KSZ8051=y : Select the KSZ8051 PHY (for EMAC), OR
CONFIG_ETH0_PHY_KSZ90x1=y : Select the KSZ9021/31 PHY (for GMAC)
Application Configuration -> Network Utilities
CONFIG_NETDB_DNSCLIENT=y : Enable host address resolution
CONFIG_NETUTILS_TELNETD=y : Enable the Telnet daemon
CONFIG_NETUTILS_TFTPC=y : Enable TFTP data file transfers for get and put commands
CONFIG_NETUTILS_NETLIB=y : Network library support is needed
CONFIG_NETUTILS_WEBCLIENT=y : Needed for wget support
: Defaults should be okay for other options
Application Configuration -> NSH Library
CONFIG_NSH_TELNET=y : Enable NSH session via Telnet
CONFIG_NSH_IPADDR=0x0a000002 : Select an IP address
CONFIG_NSH_DRIPADDR=0x0a000001 : IP address of gateway/host PC
CONFIG_NSH_NETMASK=0xffffff00 : Netmask
CONFIG_NSH_NOMAC=y : Need to make up a bogus MAC address
: Defaults should be okay for other options
Using the network with NSH
--------------------------
So what can you do with this networking support? First you see that
NSH has several new network related commands:
ifconfig, ifdown, ifup: Commands to help manage your network
get and put: TFTP file transfers
wget: HTML file transfers
ping: Check for access to peers on the network
Telnet console: You can access the NSH remotely via telnet.
You can also enable other add on features like full FTP or a Web
Server or XML RPC and others. There are also other features that
you can enable like DHCP client (or server) or network name
resolution.
By default, the IP address of the SAMA5D3x-EK will be 10.0.0.2 and
it will assume that your host is the gateway and has the IP address
10.0.0.1.
nsh> ifconfig
eth0 HWaddr 00:e0:de:ad:be:ef at UP
IPaddr:10.0.0.2 DRaddr:10.0.0.1 Mask:255.255.255.0