title: How do I resolve this error in the Raspberry Pi Kernel file bounds.c?
body: <p>I am new to kernel compilation. I want to create the Blinking LED driver for Raspberry Pi 1 Model B but as a first step towards the goal, I am trying to cross-compile unmodified Raspberry pi Kernel and following <a href="https://kerneltweaks.wordpress.com/2014/06/09/led-blinking-driver-for-raspberry-pi/" rel="nofollow noreferrer">this article.</a></p>
  
  <p>Everything goes fine until step 7. In step 7, when I enter cross compile command, it shows this:</p>
  
  <pre><code>$ make ARCH=arm CROSS_COMPILE=${CCPREFIX}  
    CHK     include/config/kernel.release
    CHK     include/generated/uapi/linux/version.h
    CHK     include/generated/utsrelease.h
  make[1]: 'include/generated/mach-types.h' is up to date.
    CC      kernel/bounds.s
  In file included from ./arch/arm/include/asm/bug.h:6:0,
                   from include/linux/bug.h:4,
                   from include/linux/page-flags.h:9,
                   from kernel/bounds.c:9:
  ./arch/arm/include/asm/opcodes.h:14:52: error: unknown type name 'u32'
  ./arch/arm/include/asm/opcodes.h:14:64: error: unknown type name 'u32'
  In file included from ./arch/arm/include/asm/irqflags.h:6:0,
                   from include/linux/irqflags.h:15,
                   from ./arch/arm/include/asm/bitops.h:27,
                   from include/linux/bitops.h:36,
                   from include/linux/log2.h:16,
                   from kernel/bounds.c:12:
  ./arch/arm/include/asm/ptrace.h:125:1: error: unknown type name 'bool'
  ./arch/arm/include/asm/ptrace.h: In function 'regs_get_register':
  ./arch/arm/include/asm/ptrace.h:141:6: error: expected expression before 'struct'
  In file included from include/linux/bitops.h:36:0,
                   from include/linux/log2.h:16,
                   from kernel/bounds.c:12:
  ./arch/arm/include/asm/bitops.h: In function '____atomic_set_bit':
  ./arch/arm/include/asm/bitops.h:38:23: error: 'BITS_PER_LONG' undeclared (first use in this function)
  ./arch/arm/include/asm/bitops.h:38:23: note: each undeclared identifier is reported only once for each function it appears in
  ./arch/arm/include/asm/bitops.h: In function '____atomic_clear_bit':
  ./arch/arm/include/asm/bitops.h:50:23: error: 'BITS_PER_LONG' undeclared (first use in this function)
  ./arch/arm/include/asm/bitops.h: In function '____atomic_change_bit':
  ./arch/arm/include/asm/bitops.h:62:23: error: 'BITS_PER_LONG' undeclared (first use in this function)
  ./arch/arm/include/asm/bitops.h: In function '____atomic_test_and_set_bit':
  ./arch/arm/include/asm/bitops.h:76:23: error: 'BITS_PER_LONG' undeclared (first use in this function)
  ./arch/arm/include/asm/bitops.h: In function '____atomic_test_and_clear_bit':
  ./arch/arm/include/asm/bitops.h:93:23: error: 'BITS_PER_LONG' undeclared (first use in this function)
  ./arch/arm/include/asm/bitops.h: In function '____atomic_test_and_change_bit':
  ./arch/arm/include/asm/bitops.h:110:23: error: 'BITS_PER_LONG' undeclared (first use in this function)
  In file included from ./arch/arm/include/asm/bitops.h:122:0,
                   from include/linux/bitops.h:36,
                   from include/linux/log2.h:16,
                   from kernel/bounds.c:12:
  include/asm-generic/bitops/non-atomic.h: In function '__set_bit':
  include/asm-generic/bitops/non-atomic.h:17:23: error: 'BITS_PER_LONG' undeclared (first use in this function)
  include/asm-generic/bitops/non-atomic.h: In function '__clear_bit':
  include/asm-generic/bitops/non-atomic.h:25:23: error: 'BITS_PER_LONG' undeclared (first use in this function)
  include/asm-generic/bitops/non-atomic.h: In function '__change_bit':
  include/asm-generic/bitops/non-atomic.h:42:23: error: 'BITS_PER_LONG' undeclared (first use in this function)
  include/asm-generic/bitops/non-atomic.h: In function '__test_and_set_bit':
  include/asm-generic/bitops/non-atomic.h:59:23: error: 'BITS_PER_LONG' undeclared (first use in this function)
  include/asm-generic/bitops/non-atomic.h: In function '__test_and_clear_bit':
  include/asm-generic/bitops/non-atomic.h:78:23: error: 'BITS_PER_LONG' undeclared (first use in this function)
  include/asm-generic/bitops/non-atomic.h: In function '__test_and_change_bit':
  include/asm-generic/bitops/non-atomic.h:90:23: error: 'BITS_PER_LONG' undeclared (first use in this function)
  include/asm-generic/bitops/non-atomic.h: In function 'test_bit':
  include/asm-generic/bitops/non-atomic.h:105:21: error: 'BITS_PER_LONG' undeclared (first use in this function)
  In file included from ./arch/arm/include/asm/bitops.h:312:0,
                   from include/linux/bitops.h:36,
                   from include/linux/log2.h:16,
                   from kernel/bounds.c:12:
  include/asm-generic/bitops/fls64.h: At top level:
  include/asm-generic/bitops/fls64.h:33:2: error: #error BITS_PER_LONG not 32 or 64
  In file included from ./arch/arm/include/asm/bitops.h:314:0,
                   from include/linux/bitops.h:36,
                   from include/linux/log2.h:16,
                   from kernel/bounds.c:12:
  include/asm-generic/bitops/sched.h: In function 'sched_find_first_bit':
  include/asm-generic/bitops/sched.h:27:2: error: #error BITS_PER_LONG not defined
  In file included from include/linux/log2.h:16:0,
                   from kernel/bounds.c:12:
  include/linux/bitops.h: At top level:
  include/linux/bitops.h:202:37: error: unknown type name 'u64'
  include/linux/bitops.h:208:2: error: #error BITS_PER_LONG not 32 or 64
  In file included from kernel/bounds.c:12:0:
  include/linux/log2.h:32:17: error: unknown type name 'u32'
  include/linux/log2.h:40:17: error: unknown type name 'u64'
  include/linux/log2.h:52:1: error: unknown type name 'bool'
  Kbuild:44: recipe for target 'kernel/bounds.s' failed
  make[1]: *** [kernel/bounds.s] Error 1
  Makefile:1004: recipe for target 'prepare0' failed
  make: *** [prepare0] Error 2
  </code></pre>
  
  <p>I have not made any changes in any kernel file. I am not sure why bounds.c has a problem. Also, I downloaded the compressed version of the kernel file so I don't think it is a checkout/update issue. I have to confess I am confused as to what this error actually means. Am I missing something?</p>
  
  <p>Thanks in advance</p>
  
  <p>EDIT: 
  (1) <code>printenv</code> before step #6</p>
  
  <pre><code>$ printenv
  XDG_VTNR=7
  XDG_SESSION_ID=c2
  CLUTTER_IM_MODULE=xim
  XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/omkar
  SESSION=ubuntu
  GPG_AGENT_INFO=/home/omkar/.gnupg/S.gpg-agent:0:1
  SHELL=/bin/bash
  TERM=xterm-256color
  VTE_VERSION=4205
  QT_LINUX_ACCESSIBILITY_ALWAYS_ON=1
  WINDOWID=58720266
  KERNEL_SRC=/home/bhargav/rpi/linux-rpi-3.2.27
  OLDPWD=/home/omkar/rpi
  UPSTART_SESSION=unix:abstract=/com/ubuntu/upstart-session/1000/1623
  GNOME_KEYRING_CONTROL=
  GTK_MODULES=gail:atk-bridge:unity-gtk-module
  USER=omkar
  LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
  QT_ACCESSIBILITY=1
  XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
  XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
  SSH_AUTH_SOCK=/run/user/1000/keyring/ssh
  DEFAULTS_PATH=/usr/share/gconf/ubuntu.default.path
  XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/usr/share/upstart/xdg:/etc/xdg
  PATH=/home/omkar/bin:/home/omkar/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
  DESKTOP_SESSION=ubuntu
  QT_IM_MODULE=ibus
  QT_QPA_PLATFORMTHEME=appmenu-qt5
  XDG_SESSION_TYPE=x11
  PWD=/home/omkar/rpi/linux-rpi-4.4.y
  JOB=unity-settings-daemon
  XMODIFIERS=@im=ibus
  GNOME_KEYRING_PID=
  LANG=en_US.UTF-8
  GDM_LANG=en_US
  MANDATORY_PATH=/usr/share/gconf/ubuntu.mandatory.path
  IM_CONFIG_PHASE=1
  COMPIZ_CONFIG_PROFILE=ubuntu
  GDMSESSION=ubuntu
  SESSIONTYPE=gnome-session
  GTK2_MODULES=overlay-scrollbar
  HOME=/home/omkar
  XDG_SEAT=seat0
  SHLVL=1
  LANGUAGE=en_US
  GNOME_DESKTOP_SESSION_ID=this-is-deprecated
  UPSTART_INSTANCE=
  UPSTART_EVENTS=xsession started
  XDG_SESSION_DESKTOP=ubuntu
  LOGNAME=omkar
  COMPIZ_BIN_PATH=/usr/bin/
  QT4_IM_MODULE=xim
  XDG_DATA_DIRS=/usr/share/ubuntu:/usr/share/gnome:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
  DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-S9i5BrLSwB
  CCPREFIX=/home/omkar/rpi/tools-master/arm-bcm2708/arm-bcm2708-linux-gnueabi/bin/arm-bcm2708-linux-gnueabi-
  LESSOPEN=| /usr/bin/lesspipe %s
  INSTANCE=
  UPSTART_JOB=unity7
  XDG_RUNTIME_DIR=/run/user/1000
  DISPLAY=:0
  XDG_CURRENT_DESKTOP=Unity
  GTK_IM_MODULE=ibus
  LESSCLOSE=/usr/bin/lesspipe %s %s
  XAUTHORITY=/home/omkar/.Xauthority
  _=/usr/bin/printenv
  </code></pre>
  
  <p>(2) Output of step #6</p>
  
  <pre><code>$ make ARCH=arm CROSS_COMPILE=${CCPREFIX} bcmrpi_defconfig
    HOSTCC  scripts/basic/fixdep
    HOSTCC  scripts/kconfig/conf.o
    SHIPPED scripts/kconfig/zconf.tab.c
    SHIPPED scripts/kconfig/zconf.lex.c
    SHIPPED scripts/kconfig/zconf.hash.c
    HOSTCC  scripts/kconfig/zconf.tab.o
    HOSTLD  scripts/kconfig/conf
  #
  # configuration written to .config
  #
  </code></pre>