-
Notifications
You must be signed in to change notification settings - Fork 4
/
new_board.sh
executable file
·133 lines (121 loc) · 5.56 KB
/
new_board.sh
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
#!/bin/bash
# Script to help automate adding a new board
# extract the list of board names from the board.cfg file
board_list=`fgrep -v '#' boards.cfg | awk '{print $4}' | uniq`
donor_board=""
echo "This script will create a new board. It will overwrite all of"
echo "the configuration files for the new board if they exists but it"
echo "will by no means completely replace everything. Press ^C"
echo "if you do not wish to continue."
echo
echo "Please enter the number for a donor board to use as the base for the new board."
echo "The donor board is often the evaulation board; see the SDK documentation on"
echo "porting a new board to U-Boot for more information on donor board selection."
select donor_board in $board_list ; do
if [ ! -z "$donor_board" ] ; then
echo "$donor_board selected"
break;
fi
done
new_board=""
while [ -z ${new_board} ] ; do
echo
echo "Enter the name for the new board (without the \"octeon_\")"
echo "It should be lower case and all one word, for example, foo6800"
echo -n "Enter new board name: "
read new_board
done
echo
echo "The new board name will be octeon_${new_board}"
grep "octeon_$new_board" boards.cfg >/dev/null
if [ "$?" = "0" ] ; then
echo "$new_board already exists in boards.cfg."
fi
echo
echo "Do you want to continue? [1=yes, 2=no]"
select answer in "yes" "no" ; do
case "$answer" in
"yes" ) break ;;
"no" ) echo "Exiting at you request."; exit 1;;
esac
done
echo
echo "Does the $new_board support PCI/PCIe host mode? [1=yes, 2=no]"
select pci_host in "yes" "no" ; do
case "$pci_host" in
"yes" ) pci_host="1"; break ;;
"no" ) pci_host="0"; break ;;
esac
done
echo "Setting up the files and directories for ${new_board},"
echo "using donor board ${donor_board}:"
echo " Copying configuration file(s)..."
cp -f "include/configs/octeon_${donor_board}.h" "include/configs/octeon_${new_board}.h"
shared_board=`grep '^#include \"octeon_.*_shared.h' "include/configs/octeon_${donor_board}.h" | awk '{print $2}' | sed s/\"//g`
#Translate new board name into all upper case to creat the defines
new_board_upper=`echo "${new_board}" | tr a-z A-Z`
donor_board_upper=`echo "octeon_"$donor_board | tr a-z A-Z`
if [ ! -z "$shared_board" ] ; then
echo " Found memory configuration file $shared_board"
echo " Copying $shared_board to octeon_${new_board}_shared.h..."
cp -f "include/configs/${shared_board}" "include/configs/octeon_${new_board}_shared.h"
# Changing the shared include file name in octeon_${new_board}.h
echo " Changing the shared include file name in octeon_${new_board}.h..."
sed -i "s/octeon_${donor_board}_shared.h/octeon_${new_board}.h/" "include/configs/octeon_${new_board}_shared.h"
sed -i "s/__${donor_board_upper}_SHARED_H__/__OCTEON_${new_board_upper}_SHARED_H__/g" "include/configs/octeon_${new_board}_shared.h"
fi
echo " Creating directory board/octeon/$new_board..."
mkdir -p "board/octeon/"$new_board
echo " Copying files and creating symbolic links..."
cp "board/octeon/${donor_board}/${donor_board}_board.c" "board/octeon/${new_board}/${new_board}_board.c"
cp "board/octeon/${donor_board}/${donor_board}.dts" "board/octeon/${new_board}/${new_board}.dts"
cd "board/octeon/${new_board}"
echo " Creating links to Makefile and make components in common_make..."
ln -sf ../common_make/Makefile .
ln -sf ../common_make/config.mk .
cd ../../..
# Add board to boards.cfg
echo " Adding $new_board to boards.cfg..."
grep "octeon_$new_board" boards.cfg >/dev/null
if [ "$?" = "0" ] ; then
echo " (The board $new_board already exists in boards.cfg. Replacing existing entry...)"
sed -i '/^octeon_'$new_board'.*/d' boards.cfg
fi
echo "octeon_${new_board} mips octeon ${new_board} octeon - octeon_${new_board}:OCTEON_${new_board_upper},OCTEON_PCI_HOST=${pci_host}" >> boards.cfg
rm -f .boards.depend
echo
echo "Done creating files and directories for board ${target_board}"
echo
echo "Please take the following steps:"
echo "1) Edit cvmx-app-init.h in the executive directory to add the new board ${new_board}:"
echo " 1a) Add CVMX_BOARD_TYPE_CUST_${new_board_upper} to cvmx_board_type_enum list"
echo " 1b) Add CVMX_BOARD_TYPE_CUST_PRIVATE_${new_board_upper} to the function"
echo " cvmx_board_type_to_string()"
echo
echo "2). Edit arch/mips/cpu/octeon/lib_octeon_shared.c:"
echo " 2a) Add the include configs/octeon_${new_board}_shared.h near include for"
echo " octeon_${donor_board}_shared.h."
echo " 2b) Add compiled-in spd array entry to for the new board ${new_board},"
echo " duplicating the sections for the ${donor_board} board."
echo " 2c) Add entry to octeon_board_ddr_config_table array for the new board"
echo " ${new_board}, duplicating the sections for the ${donor_board} board."
echo " 2d) Search for CONFIG_OCTEON_"$donor_board_upper" to find any other the areas in"
echo " lib_octeon_shared.c which need to be edited."
echo
echo "To build the boot loader, type: make octeon_${new_board}_config"
echo "This will create the file config.h which tells the Makefile which board to build."
echo "Then type: make"
echo
echo "If the donor board is an available evaluation board, then after the build is"
echo "complete, install u-boot-octeon_${new_board}.bin onto the donor board to "
echo "verify this process completed without error."
echo
echo "The next step is to start editing include/configs/octeon_${new_board}.h,"
echo "include/configs/octeon_${new_board}_shared.h,"
echo "board/octeon/${new_board}/${new_board}.dts and"
echo "board/octeon/${new_board}/${new_board}_board.c to customize them for the new board."
echo "See the U-Boot porting guide supplied with the SDK documentation for help."
echo
echo
echo "Have fun!"
exit 0