150 stars
You need EXACTLY all 150 stars in the game to unlock the cannon outside the castle, there is no cheat to get them all or a cheat to get the cannon without obtaining all the stars.
If you need more help, we've got more Super Mario 64 DS cheats and also check out all of the answers for this game
Comments for this hint