Make sure that you have run this script https://github.com/DexterInd/GrovePi/blob/master/Script/install.sh.
Use the Arduino IDE on the VNC to compile the ino file. Change the programmer to “Raspberry Pi GPIO”. Connect the jumpers in the same way as when updating the firmware and press “Ctrl+Shift+U” to upload the sketch to the GrovePi.
For the manual method from the terminal, open the Arduino IDE, goto File -> Preferences, and select the verbose mode in compilation.
Compile the sketch and copy the path shown in the Arduino IDE on the bottom for the hex file.
Then run this:
avrdude -c gpio -p m328p -U flash:w:path_to_file.hex
to upload the code.