1 From 1b77d4249b5addbf3b0848db6992a445019a1865 Mon Sep 17 00:00:00 2001
2 From: Luka Perkov <luka@openwrt.org>
3 Date: Wed, 29 Aug 2012 22:08:42 +0200
4 Subject: tools: add some helper tools for Lantiq SoCs
6 Signed-off-by: Luka Perkov Luka Perkov <luka@openwrt.org>
7 Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
34 + die("\n Syntax: perl gct.pl uart_ddr_settings.conf u-boot.srec u-boot.asc\n");
37 +open(IN_UART_DDR_SETTINGS, "<$ARGV[0]") || die("failed to open uart_ddr_settings.conf\n");
38 +open(IN_UART_SREC, "<$ARGV[1]") || die("failed to open u-boot.srec\n");
39 +open(OUT_UBOOT_ASC, ">$ARGV[2]") || die("failed to open u-boot.asc\n");
42 +while ($line = <IN_UART_DDR_SETTINGS>){
44 + if($line!~/[;#\*]/){
46 + printf OUT_UBOOT_ASC ("33333333");
50 + @array=split(/ +/,$line);
52 + while(@array[$j]!~/\w/){
56 + $regval=@array[$j+1];
59 + printf OUT_UBOOT_ASC ("%08x%08x",hex($addr),hex($regval));
63 + printf OUT_UBOOT_ASC ("\n");
69 +while($i lt 8 && $i gt 0){
70 + printf OUT_UBOOT_ASC "00"x8;
75 + printf OUT_UBOOT_ASC ("\n");
78 +while($aline=<IN_UART_SREC>){
81 + next if(($aline=~/^S0/) || ($aline=~/^S7/));
82 + ($lineid, $length, $address, @bytes) = unpack"A2A2A8"."A2"x300, $aline;
83 + $length = hex($length);
84 + $address = hex($address);
90 + $addstr = sprintf("%x", $address);
91 + $addstr = "0"x(8-length($addstr)).$addstr;
92 + print OUT_UBOOT_ASC $addstr;
95 + $currentaddr=$address;
96 + $loadaddr = $addstr;
100 + $addstr = sprintf("%x", $currentaddr);
101 + $addstr = "0"x(8-length($addstr)).$addstr;
102 + print OUT_UBOOT_ASC $addstr;
106 +#printf("*** %x != %x\n", $address, $currentaddr) if $address != $currentaddr;
108 + if($currentaddr < $address) {
109 + print OUT_UBOOT_ASC "00";
116 + $bytes[$i]=~tr/ABCDEF/abcdef/;
117 + print OUT_UBOOT_ASC "$bytes[$i]";
118 + addchsum($bytes[$i]);
123 + last if($length==0);
127 + print OUT_UBOOT_ASC "\n";
133 + for($i=0;$i<(64-$count);$i++){
134 + print OUT_UBOOT_ASC "00";
137 + print OUT_UBOOT_ASC "\n";
141 +print OUT_UBOOT_ASC "11"x4;
143 +$chsum=$chsum & 0xffffffff;
144 +$chsum = sprintf("%X", $chsum);
145 +$chsum = "0"x(8-length($chsum)).$chsum;
146 +$chsum =~tr/ABCDEF/abcdef/;
147 +print OUT_UBOOT_ASC $chsum;
148 +print OUT_UBOOT_ASC "00"x60;
149 +print OUT_UBOOT_ASC "\n";
151 +print OUT_UBOOT_ASC "99"x4;
152 +print OUT_UBOOT_ASC $loadaddr;
153 +print OUT_UBOOT_ASC "00"x60;
154 +print OUT_UBOOT_ASC "\n";
156 +close OUT_UBOOT_ASC;
160 + $holder=$holder.$cc;
161 + if(length($holder)==8){
162 + $holder = hex($holder);
168 +++ b/tools/lantiq_extract_openwrt_patches.sh
177 +openwrt_root=$(readlink -f $1)
178 +test -d $openwrt_root
180 +uboot_lantiq_dir=$openwrt_root/package/boot/uboot-lantiq/patches
181 +test -d $uboot_lantiq_dir
183 +rm -vf $uboot_lantiq_dir/*
184 +git format-patch -k -p --no-renames --text --full-index -o $uboot_lantiq_dir v2012.10..openwrt/v2013.01
186 +++ b/tools/lantiq_ram_extract_magic.awk
189 +# This file is released under the terms of GPL v2 and any later version.
190 +# See the file COPYING in the root directory of the source tree for details.
192 +# Copyright (C) 2011 Luka Perkov <luka@openwrt.org>
194 +# usage: mips-openwrt-linux-objdump -EB -b binary -m mips:isa32r2 -D YOUR_IMAGE_DUMP | awk -f lantiq_ram_extract_magic.awk
199 + print " * This file is released under the terms of GPL v2 and any later version. "
200 + print " * See the file COPYING in the root directory of the source tree for details. "
202 + print " * generated with lantiq_ram_extract_magic.awk "
204 + print " * Copyright (C) 2011 Luka Perkov <luka@openwrt.org> "
211 + mc_dc_value_print=0
212 + mc_dc_number_print=0
216 + if (right_section) {
217 + split($4, tmp, ",")
218 + mc_dc_value=sprintf("%X", tmp[2])
219 + mc_dc_value_print=1
224 + if (right_section) {
225 + split($4, tmp, ",0x")
226 + mc_dc_value=sprintf("%s", tmp[2])
227 + mc_dc_value=toupper(mc_dc_value)
228 + mc_dc_value_print=1
232 +/t2,[0-9]+\(t1\)$/ {
233 + if (right_section) {
234 + split($4, tmp, ",")
235 + split(tmp[2], tmp, "(")
236 + mc_dc_number=tmp[1]/16
237 + mc_dc_number_print=1
242 + if (right_section && mc_dc_number_print && mc_dc_value_print) {
243 + if (mc_dc_number < 10)
244 + print "#define MC_DC0" mc_dc_number "_VALUE\t0x" mc_dc_value
246 + print "#define MC_DC" mc_dc_number "_VALUE\t0x" mc_dc_value
247 + mc_dc_value_print=0
248 + mc_dc_number_print=0
251 + if ($4 == "t1,t1,0x1000")
255 + if ($4 == "t2,736(t1)")
259 +++ b/tools/lantiq_ram_init_uart.awk
263 +# This file is released under the terms of GPL v2 and any later version.
264 +# See the file COPYING in the root directory of the source tree for details.
266 +# Copyright (C) 2011-2012 Luka Perkov <luka@openwrt.org>
267 +# Copyright (C) 2012 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
269 +# usage: awk -f lantiq_ram_init_uart.awk -v soc=<danube|ar9|vr9> PATH_TO_BOARD/ddr_settings.h
272 +function print_header()
275 + print "; This file is released under the terms of GPL v2 and any later version. "
276 + print "; See the file COPYING in the root directory of the source tree for details. "
278 + print "; generated with lantiq_ram_init_uart.awk "
280 + print "; Copyright (C) 2011-2012 Luka Perkov <luka@openwrt.org> "
281 + print "; Copyright (C) 2012 Daniel Schwierzeck <daniel.schwierzeck@gmail.com> "
286 +function mc_ddr1_prologue()
288 + /* Clear access error log registers */
289 + print "0xbf800010", "0x0"
290 + print "0xbf800020", "0x0"
292 + /* Enable DDR and SRAM module in memory controller */
293 + print "0xbf800060", "0x5"
295 + /* Clear start bit of DDR memory controller */
296 + print "0xbf801030", "0x0"
299 +function mc_ddr1_epilogue()
301 + /* Set start bit of DDR memory controller */
302 + print "0xbf801030", "0x100"
305 +function mc_ddr2_prologue()
307 + /* Put memory controller in inactive mode */
308 + print "0xbf401070", "0x0"
311 +function mc_ddr2_epilogue(mc_ccr07_value)
313 + /* Put memory controller in active mode */
314 + mc_ccr07_value = or(mc_ccr07_value, 0x100)
315 + printf("0xbf401070 0x%x\n", mc_ccr07_value)
322 + reg_base = 0xbf801000
327 + reg_base = 0xbf401000
332 + print "Invalid or no value for soc specified!"
340 + printf("0x%x %s\n", reg_base, tolower($3))
344 +/^#define(.*)MC_CCR07_VALUE/ {
345 + printf("0x%x %s\n", reg_base, tolower($3))
347 + mc_ccr07_value = strtonum($3)
357 + mc_ddr2_epilogue(mc_ccr07_value)