freemyipod r181 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r180‎ | r181 | r182 >
Date:00:40, 27 August 2010
Author:theseven
Status:new
Tags:
Comment:
Fix an annoying Makefile bug that was reponsible for corrupting my nano2g's NOR flash contents, shut down the LCD properly before powering off
Modified paths:
  • /apps/installer-nano2g/Makefile (modified) (history)
  • /embios/trunk/lcd.h (modified) (history)
  • /embios/trunk/shutdown.c (modified) (history)
  • /embios/trunk/target/ipodnano2g/backlight.c (modified) (history)
  • /embios/trunk/target/ipodnano2g/lcd.S (modified) (history)
  • /embios/trunk/target/ipodnano2g/target.h (modified) (history)

Diff [purge]

Index: apps/installer-nano2g/Makefile
@@ -153,6 +153,8 @@
154154 flashfiles: $(FLASHFILES)
155155 @touch flashfiles.built
156156
 157+$(UNINSTDIR)/build/uninstaller-nano2g.embiosapp.ucl: uninstaller-nano2g
 158+
157159 flashfiles/uninstaller-nano2g.embiosapp.ucl: $(UNINSTDIR)/build/uninstaller-nano2g.embiosapp.ucl uninstaller-nano2g
158160 @echo [CP] $@
159161 @cp $< $@
@@ -165,10 +167,14 @@
166168 @echo [UCL] $<
167169 @$(UCLPACK) $< $@
168170
 171+$(ILOADERDIR)/build/iloader.embiosapp.ucl: iloader
 172+
169173 flashfiles/iloader.embiosapp.ucl: $(ILOADERDIR)/build/iloader.embiosapp.ucl iloader
170174 @echo [CP] $@
171175 @cp $< $@
172176
 177+$(EMBIOSDIR)/loader/ipodnano2g/build/embiosldr-ipodnano2g.dfu: embiosldr-ipodnano2g
 178+
173179 flashfiles/embiosldr-ipodnano2g.dfu: $(EMBIOSDIR)/loader/ipodnano2g/build/embiosldr-ipodnano2g.dfu embiosldr-ipodnano2g
174180 @echo [CP] $@
175181 @cp $< $@
@@ -177,7 +183,9 @@
178184 @echo [UCL] $<
179185 @$(UCLPACK) $< $@
180186
181 - flashfiles/embios-ipodnano2g.bin: $(EMBIOSDIR)/build/ipodnano2g/embios.bin embios
 187+$(EMBIOSDIR)/build/ipodnano2g/embios.bin: embios
 188+
 189+flashfiles/embios-ipodnano2g.bin: $(EMBIOSDIR)/build/ipodnano2g/embios.bin embios
182190 @echo [EMBCFG] $@
183191 @$(EMBIOSBOOTCFG) $< $@ --file=/iLoader/boot.embiosapp --file-compressed --file-run-from=0x08000000 \
184192 --flash=iloader --flash-compressed --flash-run-from=0x09e00000
Index: embios/trunk/target/ipodnano2g/lcd.S
@@ -34,6 +34,69 @@
3535 mov pc, lr
3636 .size lcd_init, .-lcd_init
3737
 38+.section .icode.lcd_shutdown, "ax", %progbits
 39+.align 2
 40+.global lcd_shutdown
 41+.type lcd_shutdown, %function
 42+lcd_shutdown:
 43+ stmfd sp!, {r4, lr}
 44+ bl displaylcd_detectlcd
 45+ sub r12, r12, #0x04900000
 46+ cmp r0, #2
 47+ beq lcd_shutdown_type2
 48+ mov r0, #0x28
 49+ bl displaylcd_sendlcdc
 50+ mov r0, #0x10
 51+ bl displaylcd_sendlcdc
 52+ b lcd_shutdown_done
 53+lcd_shutdown_type2:
 54+ mov r0, #0x07
 55+ bl displaylcd_sendlcd2c
 56+ mov r0, #0x200
 57+ orr r0, r0, #0x32
 58+ bl displaylcd_sendlcd2d
 59+ mov r0, #0x13
 60+ bl displaylcd_sendlcd2c
 61+ mov r0, #0x1100
 62+ orr r0, #0x37
 63+ bl displaylcd_sendlcd2d
 64+ mov r0, #0x07
 65+ bl displaylcd_sendlcd2c
 66+ mov r0, #0x200
 67+ orr r0, r0, #0x01
 68+ bl displaylcd_sendlcd2d
 69+ mov r0, #0x13
 70+ bl displaylcd_sendlcd2c
 71+ mov r0, #0x100
 72+ orr r0, #0x37
 73+ bl displaylcd_sendlcd2d
 74+ mov r0, #0x07
 75+ bl displaylcd_sendlcd2c
 76+ mov r0, #0x200
 77+ bl displaylcd_sendlcd2d
 78+ mov r0, #0x10
 79+ bl displaylcd_sendlcd2c
 80+ mov r0, #0x680
 81+ bl displaylcd_sendlcd2d
 82+ mov r0, #0x12
 83+ bl displaylcd_sendlcd2c
 84+ mov r0, #0x160
 85+ bl displaylcd_sendlcd2d
 86+ mov r0, #0x13
 87+ bl displaylcd_sendlcd2c
 88+ mov r0, #0x100
 89+ orr r0, r0, #0x27
 90+ bl displaylcd_sendlcd2d
 91+ mov r0, #0x10
 92+ bl displaylcd_sendlcd2c
 93+ mov r0, #0x600
 94+ bl displaylcd_sendlcd2d
 95+lcd_shutdown_done:
 96+ ldmfd sp!, {r4, lr}
 97+ mov r0, #5120
 98+ b sleep
 99+.size lcd_shutdown, .-lcd_shutdown
 100+
38101 .section .text.lcd_get_width, "ax", %progbits
39102 .align 2
40103 .global lcd_get_width
Index: embios/trunk/target/ipodnano2g/backlight.c
@@ -1,42 +1,42 @@
2 -//
3 -//
4 -// Copyright 2010 TheSeven
5 -//
6 -//
7 -// This file is part of emBIOS.
8 -//
9 -// emBIOS is free software: you can redistribute it and/or
10 -// modify it under the terms of the GNU General Public License as
11 -// published by the Free Software Foundation, either version 2 of the
12 -// License, or (at your option) any later version.
13 -//
14 -// emBIOS is distributed in the hope that it will be useful,
15 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
16 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 -// See the GNU General Public License for more details.
18 -//
19 -// You should have received a copy of the GNU General Public License along
20 -// with emBIOS. If not, see <http://www.gnu.org/licenses/>.
21 -//
22 -//
23 -
24 -
25 -#include "global.h"
26 -#include "i2c.h"
27 -#include "backlight.h"
28 -
29 -
30 -void backlight_on(bool on)
31 -{
 2+//
 3+//
 4+// Copyright 2010 TheSeven
 5+//
 6+//
 7+// This file is part of emBIOS.
 8+//
 9+// emBIOS is free software: you can redistribute it and/or
 10+// modify it under the terms of the GNU General Public License as
 11+// published by the Free Software Foundation, either version 2 of the
 12+// License, or (at your option) any later version.
 13+//
 14+// emBIOS is distributed in the hope that it will be useful,
 15+// but WITHOUT ANY WARRANTY; without even the implied warranty of
 16+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 17+// See the GNU General Public License for more details.
 18+//
 19+// You should have received a copy of the GNU General Public License along
 20+// with emBIOS. If not, see <http://www.gnu.org/licenses/>.
 21+//
 22+//
 23+
 24+
 25+#include "global.h"
 26+#include "i2c.h"
 27+#include "backlight.h"
 28+
 29+
 30+void backlight_on(bool on)
 31+{
3232 i2c_sendbyte(0, 0xe6, 0x29, on ? 1 : 0);
33 -}
34 -
35 -void backlight_set_fade(uint8_t fade)
36 -{
 33+}
 34+
 35+void backlight_set_fade(uint8_t fade)
 36+{
3737 i2c_sendbyte(0, 0xe6, 0x2b, fade);
38 -}
39 -
40 -void backlight_set_brightness(uint8_t brightness)
41 -{
 38+}
 39+
 40+void backlight_set_brightness(uint8_t brightness)
 41+{
4242 i2c_sendbyte(0, 0xe6, 0x28, (46 * (brightness & 0xff)) >> 8);
43 -}
 43+}
Index: embios/trunk/target/ipodnano2g/target.h
@@ -41,6 +41,7 @@
4242 #define USB_NUM_ENDPOINTS 5
4343
4444 #define HAVE_LCD
 45+#define HAVE_LCD_SHUTDOWN
4546 #define LCD_WIDTH 176
4647 #define LCD_HEIGHT 132
4748 #define LCD_FORMAT rgb565
Index: embios/trunk/lcd.h
@@ -32,6 +32,7 @@
3333
3434
3535 void lcd_init() INITCODE_ATTR;
 36+void lcd_shutdown();
3637 int lcd_get_width() ICODE_ATTR;
3738 int lcd_get_height() ICODE_ATTR;
3839 int lcd_get_bytes_per_pixel() ICODE_ATTR;
Index: embios/trunk/shutdown.c
@@ -31,4 +31,14 @@
3232 #ifdef HAVE_STORAGE_FLUSH
3333 storage_flush();
3434 #endif
 35+ if (shutdownhw)
 36+ {
 37+#ifdef HAVE_BACKLIGHT
 38+ backlight_set_fade(0);
 39+ backlight_on(false);
 40+#endif
 41+#ifdef HAVE_LCD_SHUTDOWN
 42+ lcd_shutdown();
 43+#endif
 44+ }
3545 }