First open the Makefile file and enter the following code in it:
1 CROSS_COMPILE ?= arm-linux-gnueabihf-
2 TARGET ?= backlight
3
4 CC := $(CROSS_COMPILE)gcc
5 LD := $(CROSS_COMPILE)ld
6 OBJCOPY := $(CROSS_COMPILE)objcopy
7 OBJDUMP := $(CROSS_COMPILE)objdump
8
9 LIBPATH:= -lgcc -L /usr/local/arm/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/lib/gcc/arm -linux-gnueabihf/4.9.4
10
11
12 INCDIRS := core \
13 stdio/include \
14 drivers/clk \
15 drivers/led \
16 drivers/delay \
17 drivers/beep \
18 drivers/gpio \
19 drivers/key \
20 drivers/exit \
21 drivers/int \
22 drivers/epittimer \
23 drivers/keyfilter \
24 drivers/uart \
25 drivers/lcd \
26 drivers/rtc \
27 drivers/i2c \
28 drivers/ap3216c \
29 drivers/touchscreen \
30 drivers/backlight
31
32 SRCDIRS := ./ \
33 stdio/lib \
34 drivers/clk \
35 drivers/led \
36 drivers/delay \
37 drivers/beep \
38 drivers/gpio \
39 drivers/key \
40 drivers/exit \
41 drivers/int \
42 drivers/epittimer \
43 drivers/keyfilter \
44 drivers/uart \
45 drivers/lcd \
46 drivers/rtc \
47 drivers/i2c \
48 drivers/ap3216c \
49 drivers/touchscreen \
50 drivers/backlight
51
52
53 INCLUDE := $(patsubst %, -I %, $(INCDIRS))
54
55 SFILES := $(foreach dir, $(SRCDIRS), $(wildcard $(dir)/*.S))
56 CFILES := $(foreach dir, $(SRCDIRS), $(wildcard $(dir)/*.c))
57
58 SFILENDIR := $(notdir $(SFILES))
59 CFILENDIR := $(notdir $(CFILES))
60
61 SOBJS := $(patsubst %, output/%, $(SFILENDIR:.S=.o))
62 COBJS := $(patsubst %, output/%, $(CFILENDIR:.c=.o))
63 OBJS := $(SOBJS) $(COBJS)
64
65 VPATH := $(SRCDIRS)
66
67 .PHONY: clean
68
69 $(TARGET).bin : $(OBJS)
70 $(LD) -Timx6ul.lds -o $(TARGET).elf $^ $(LIBPATH)
71 $(OBJCOPY) -O binary -S $(TARGET).elf $@
72
73 $(SOBJS) : output/%.o : %.S
74 $(CC) -Wall -nostdlib -fno-builtin -c -O2 $(INCLUDE) -o $@ $<
75
76 $(COBJS) : output/%.o : %.c
77 $(CC) -Wall -Wa,-mimplicit-it=thumb -nostdlib -fno-builtin -c -O2 $(INCLUDE) -o $@ $<
78
79 clean:
80 rm -rf $(TARGET).elf $(TARGET).dis $(TARGET).bin $(COBJS) $(SOBJS)
We mainly modified the following places in the Makefile:
The TARGET on the second line was changed to backlight.
Added "drivers/backlight" to the variable INCDIRS on line 30.
Add "drivers/backlight" to the variable SRCDIRS on line 50.
The link script file remains unchanged.
Then enter the "make" command in the terminal to start compiling the project, as shown in Figure 1:
Compilation is complete to generate "backlight.bin" file, as shown in Figure 2:
Then enter the command "chmod 777 create_imx" in the terminal to modify the create_imx file to have executable permissions, as shown in Figure 3:
Finally, run the command "./create_imx backlight.bin" in the terminal to generate the final image file "bare.imx", as shown in Figure 4:
Then we copy the generated bare.imx file to the corresponding directory in the mfg burning tool through SSH software. For this step, please refer to the previous burning chapter. Switch the DIP switch to programming mode, power on and wait for the programming to complete, then switch the DIP switch back to startup mode, and wait for the program to run normally, we can see the LCD screen as shown in Figure 5:
We can see that the current PWM is 10%, and the screen display is relatively dark. We press the KEY0 button of the development board to adjust the PWM to 90%, as shown in Figure 6:
We can see that the screen becomes brighter.